这是一份在pvAccessCPP中实现的以下命令行工具的教程:
1) pvlist:显式一个本地局域网中的pvAccess服务器列表,或者一个对应一台特定服务器中通道的列表。
2) pvinfo:显式一个通道的检测接口。
3) pvget:获取或监视一个通道的数据。
4) pvmonitor:与pvget -m同义。
5) pvput:写数据到一个通道。
pvAccessCPP提供了命令行工具。每一个工具提供了帮助。例如:
pvlist -help
在这部分中展示的示例认为你的PATH环境变量包含了来自pvAccessCPP的合适bin目录。例如:
export PATH=$PATH:${EPICS7}/pvAccessCPP/bin/${EPICS_HOST_ARCH}
这些示例也认为你按如下已经克隆了exampleCPP:
git clone https://github.com/epics-base/exampleCPP.git
在构建了exampleCPP后,按如下启动一个示例数据库:
mrk> pwd
/home/epicsv4/masterCPP/exampleCPP/database/iocBoot/exampleDatabase
mrk> ../../bin/linux-x86_64/exampleDatabase st.cmd
在exampleDatabase被启动后,iocshell命令行支持很多命令。一些重要的命令是:
1)dbl:提供了一个所有DBRecords的列表。
2)pvdbl:提供了一个所有PVRecords的列表。
3)help:显示所有命令。
4)exit:退出IOC。
这些选项是:
1) -h:帮助:打印这条信息。
2)-V:打印版本并且退出。
3)-i:打印服务器信息(当给出服务器地址列表/GUID时)
4)-w
5)-q:安静模式,只打印错误消息。
6)-d:使能调试输出。
mrk> pvlist -help
Usage: pvlist [options] [server address or GUID starting with '0x']...
options:
-h: Help: Print this message
-V: Print version and exit
-i Print server info (when server address list/GUID is given)
-w : Wait time, specifies timeout, default is 3.000000 second(s)
-q: Quiet mode, print only error messages
-d: Enable debug output
examples:
pvlist
pvlist ioc0001
pvlist 10.5.1.205:10000
pvlist 0x83DE3C540000000000BF351F
没有带任何参数,这显示它能够定位的所有V4服务器的位置。例如:
pvlist
GUID 0xC50BFC5B000000003E347E33 version 1: tcp@[10.0.0.111:5075, 192.168.124.1:5075]
这只显示了一行,因为只运行了一个exampleDatabase服务器。在一个操作系统中,输出会相当广泛。
一旦直到了一台服务器的位置,通过请求GUID或者tcp地址能够请求通道名称的列表。因而,要么:
pvlist 0xC50BFC5B000000003E347E33
要么:
pvlist 10.0.0.111:5075
产生:
DBRao01
DBRdouble00
...
pvinfo获取对应选取通道的检测接口。选项是:
1)-h:帮助:打印这条信息。
2)-V:打印版本和退出。
3)-w
4) -p
5) -d:使能调试输出。
6) -c:等待干净的关闭并且报告使用的实例计数(用于专家用户)
mrk> pvinfo -help
Usage: pvinfo [options] ...
options:
-h: Help: Print this message
-V: Print version and exit
-w : Wait time, specifies timeout, default is 3.000000 second(s)
-p : Set default provider name, default is 'pva'
-d: Enable debug output
-c: Wait for clean shutdown and report used instance count (for expert users)
Example: pvinfo double01
一些示例:
mrk> pvinfo PVRdouble
PVRdouble
Server: 10.0.0.26:5075
Type:
epics:nt/NTScalar:1.0
double value
alarm_t alarm
int severity
int status
string message
time_t timeStamp
long secondsPastEpoch
int nanoseconds
int userTag
mrk> pvinfo DBRdouble
DBRdouble
Server: 10.0.0.26:5075
Type:
epics:nt/NTScalar:1.0
double value
alarm_t alarm
int severity
int status
string message
time_t timeStamp
long secondsPastEpoch
int nanoseconds
int userTag
structure display
double limitLow
double limitHigh
string description
string units
int precision
enum_t form
int index
string[] choices
control_t control
double limitLow
double limitHigh
double minStep
valueAlarm_t valueAlarm
boolean active
double lowAlarmLimit
double lowWarningLimit
double highWarningLimit
double highAlarmLimit
int lowAlarmSeverity
int lowWarningSeverity
int highWarningSeverity
int highAlarmSeverity
byte hysteresis
mrk> pvinfo PVRpowerSupply
PVRpowerSupply
Server: 10.0.0.194:42997
Type:
structure
alarm_t alarm
int severity
int status
string message
time_t timeStamp
long secondsPastEpoch
int nanoseconds
int userTag
structure power
double value
structure voltage
double value
structure current
double value
以下描述了pvget。
pvmonitor与以下相同:
pvget -m
pvget提供了类似于caget的功能。但它可以使用provider pva或ca去访问一个通道。它可以访问DBRecords和PVRecords。
例如:
mrk> caget DBRdouble
DBRdouble 1
mrk> pvget DBRdouble
DBRdouble 2019-04-15 15:24:08.357 1
mrk> caget PVRdouble
Channel connect timed out: 'PVRdouble' not found.
mrk> pvget PVRdouble
PVRdouble 2019-04-15 15:29:27.826 1
mrk>
这些选项是:
1)-h:帮助:打印这条信息。
2)-V:打印版本并且退出。
3)-r
4)-w
4)-p
5) -M
6) -v:显示整个结构体(隐式Raw模式)
7) -q:安静模式,只打印错误消息。
8) -d:使能调试输出。
过时的选项:
1) -q, -t, -i, -n, -F:被忽略
2)-f :错误。
输出详情:
1)-m -v:用Raw模式监视。只打印标记为变化的字段。
2)-m -vv:用Raw模式监视。突出显示标记为变化的字段,显示所有有效的字段。
3) -m -vvv:用Raw模式监视。突出显示标记为变化的字段,显示所有字段。
4) -vv:用Raw模式获取。突出显示有效字段,显示所有字段。
mrk> pvget -help
Usage: pvget [options] ...
options:
-h: Help: Print this message
-V: Print version and exit
-r : Request, specifies what fields to return and options, default is ''
-w : Wait time, specifies timeout, default is 5.000000 second(s)
-p : Set default provider name, default is 'pva'
-M : Output mode. default is 'nt'
-v: Show entire structure (implies Raw mode)
-q: Quiet mode, print only error messages
-d: Enable debug output
deprecated options:
-q, -t, -i, -n, -F: ignored
-f : errors
Output details:
-m -v: Monitor in Raw mode. Print only fields marked as changed.
-m -vv: Monitor in Raw mode. Highlight fields marked as changed, show all valid fields.
-m -vvv: Monitor in Raw mode. Highlight fields marked as changed, show all fields.
-vv: Get in Raw mode. Highlight valid fields, show all fields.
example: pvget double01
一些示例是:
mrk> pvget PVRdouble
PVRdouble 5
mrk> pvget PVRdoubleArray
PVRdoubleArray 5 1 2 3 4 5
mrk> pvget PVRenum
PVRenum zero
mrk> pvget -v PVRenum
PVRenum epics:nt/NTEnum:1.0
enum_t value (1) one
int index 1
string[] choices ["zero", "one"]
alarm_t alarm
int severity 0
int status 0
string message
time_t timeStamp 2018-11-26 10:19:40.278
long secondsPastEpoch 1543245580
int nanoseconds 277571561
int userTag 0
在一条命令中能够访问多个通道:
mrk> pvget PVRdouble01 PVRdouble02
PVRdouble01 0
PVRdouble02 0
以上示例都使用通道provider pva,即:用于网络通信的pvAccess服务器。
使用ca也是可能的。因而即使这个IOC没有V4支持,它可以访问一个V3 IOC。
mrk> pvget -p ca DBRdouble01
DBRdouble01 0
mrk> pvget -p ca -r "value,alarm,timeStamp" DBRdouble01
DBRdouble01 2019-04-16 05:48:31.010 0
pvget也可以监视,即是,它有类似camonitor的功能。
mrk> pvget -m -r "value,alarm,timeStamp" PVRdouble
PVRdouble 2019-04-16 05:50:20.004 1
PVRdouble 2019-04-16 05:51:19.018 2
当通过provider pva访问一个DBRecord,qsrv是是服务器端provider,它提供对DBRecord的访问。当provider ca被使用,(从EPICS早些年已经存在的)通道访问网络协议被用于访问这个DBRecord。一个差别是qsrv不满足选取DBRecord中一个字段子集的客户请求。
例如:
mrk> pvget -r "value" -p ca -v DBRdouble
DBRdouble structure
double value 1
mrk> pvget -r "value" -p pva -v DBRdouble
DBRdouble epics:nt/NTScalar:1.0
double value 1
alarm_t alarm
int severity 0
int status 0
string message NO_ALARM
time_t timeStamp 2019-04-16 08:46:04.215
long secondsPastEpoch 1555418764
int nanoseconds 214583119
int userTag 0
structure display
double limitLow -10
double limitHigh 10
string description
string units volts
int precision 2
enum_t form (0) Default
int index 0
string[] choices ["Default", "String", "Binary", "Decimal", "Hex", "Exponential", "Engineering"]
control_t control
double limitLow -9
double limitHigh 9
double minStep 0
valueAlarm_t valueAlarm
boolean active false
double lowAlarmLimit -8
double lowWarningLimit -6
double highWarningLimit 6
double highAlarmLimit 8
int lowAlarmSeverity 0
int lowWarningSeverity 0
int highWarningSeverity 0
int highAlarmSeverity 0
byte hysteresis 0
pvDatabaseCPP提供对连接字段的过滤器的支持。
对于一个完整的描述,见:pluginSupport
以下展示一个使用数组过滤器的示例:
mrk> pvget PVRdoubleArray
PVRdoubleArray 2019-04-16 06:06:14.841 [1,2,3,4,5,6,7,8,9,10]
mrk> pvget -r "value[array=2:6],alarm,timeStamp" PVRdoubleArray
PVRdoubleArray 2019-04-16 06:06:14.841 [3,4,5,6,7]
mrk> pvget -r "value[array=2:2:10],alarm,timeStamp" PVRdoubleArray
PVRdoubleArray 2019-04-16 06:06:14.841 [3,5,7,9]
EPICS 7发行了epics-base支持通道过滤器。
以下示例展示了一个如何使用数组过滤器的示例:
mrk> pvget DBRdoubleArray
DBRdoubleArray 2019-04-16 08:59:37.622 [1,2,3,4,5]
mrk> pvget DBRdoubleArray.[2:3]
DBRdoubleArray.[2:3] 2019-04-16 08:59:37.622 [3,4]
mrk> caget DBRdoubleArray.[2:3]
DBRdoubleArray.[2:3] 2 3 4
mrk> pvget -p ca DBRdoubleArray.[2:3]
DBRdoubleArray.[2:3] [3,4]
pvput提供了类似于caput的功能。例如:
mrk> caput DBRdouble01 1.0
Old : DBRdouble01 0
New : DBRdouble01 1
mrk> pvput DBRdouble01 2.0
Old : DBRdouble01 1
New : DBRdouble01 2
要看所有选项:
用法:
1)pvput [options]
2)pvput [options]
3)pvput [options]
4)pvput [options]
5)pvput [options]
选项:
过时的选项:
默认:自动 - 尝试值作为枚举字符串,接着作为索引编号
-n, -s, -F, -t:忽略。
-f :错误。
JSON支持出现。
mrk> pvput -help
Usage: pvput [options]
pvput [options] [ ...]
pvput [options] = ...
pvput [options]
pvput [options]
options:
-h: Help: Print this message
-V: Print version and exit
-r : Request, specifies what fields to return and options, default is ''
-w : Wait time, specifies timeout, default is 5.000000 second(s)
-p : Set default provider name, default is 'pva'
-M : Output mode. default is 'nt'
-v: Show entire structure (implies Raw mode)
-q: Quiet mode, print only error messages
-d: Enable debug output
Deprecated options:
default: Auto - try value as enum string, then as index number
-n, -s, -F, -t: ignored
-f : error
JSON support is present
Examples:
pvput double01 1.234 # shorthand
pvput double01 value=1.234
pvput arr:pv X 1.0 2.0 # shorthand (X is arbitrary and ignored)
pvput arr:pv "[1.0, 2.0]" # shorthand
pvput arr:pv value="[1.0, 2.0]"
Field values may be given with JSON syntax.
Complete structure
pvput double01 '{"value":1.234}'
Sub-structure(s)
pvput group:pv some='{"value":1.234}' other='{"value":"a string"}'
mrk> pvput PVRdouble 5
Old : PVRdouble 0
New : PVRdouble 5
mrk> pvput PVRdoubleArray '[1,2,3]'
Old : 2019-04-16 09:17:22.694 [1,2,3,4,5,6,7,8]
New : 2019-04-16 09:17:58.103 [1,2,3]
mrk> pvput PVRdoubleArray '[1,2,3,4,5,6,7,8]'
Old : 2019-04-16 09:17:58.103 [1,2,3]
New : 2019-04-16 09:18:06.830 [1,2,3,4,5,6,7,8]
mrk> pvput PVRstring 'hello world'
Old : 2019-04-16 09:20:16.703 hhh
New : 2019-04-16 09:20:44.622 hello world
mrk> pvput PVRstringArray '["a a","bbb bbb","cc ccc"]'
Old : 2019-04-16 09:21:23.936 []
New : 2019-04-16 09:22:36.855 ["a a", "bbb bbb", "cc ccc"]
mrk> pvput PVRstringArray '["a a","bbb bbb","cc ccc"]'
Old : 2019-04-16 09:21:23.936 []
New : 2019-04-16 09:22:36.855 ["a a", "bbb bbb", "cc ccc"]
写入多个字段:
pvput使用JSON语法能够写入多个字段。除了union和unionArray,它可以写入任何字段类型。
mrk> pvinfo PVRpowerSupply
PVRpowerSupply
Server: 10.0.0.194:42997
Type:
structure
alarm_t alarm
int severity
int status
string message
time_t timeStamp
long secondsPastEpoch
int nanoseconds
int userTag
structure power
double value
structure voltage
double value
structure current
double value
mrk> pvput -r "voltage" PVRpowerSupply voltage='{"value":"5"}'
Old : structure
structure voltage
double value 0
New : structure
structure voltage
double value 5
mrk> pvput -r "voltage,power" PVRpowerSupply power='{"value":1.2}' voltage='{"value":1.2}'
Old : structure
structure voltage
double value 5
structure power
double value 0
New : structure
structure voltage
double value 1.2
structure power
double value 1.2
mrk> pvinfo PVRBigRecord
PVRBigRecord
Server: 10.0.0.26:5075
Type:
structure
time_t timeStamp
long secondsPastEpoch
int nanoseconds
int userTag
structure scalar
structure boolean
boolean value
structure byte
byte value
structure long
long value
structure double
double value
structure string
string value
structure scalarArray
structure boolean
boolean[] value
structure byte
byte[] value
structure long
long[] value
structure double
double[] value
structure string
string[] value
structure[] structureArray
structure
string name
string value
union restrictedUnion
string string
string[] stringArray
any variantUnion
mrk> pvput PVRBigRecord scalar='{"boolean":{"value":true},"double":{"value":5}}'
Old : structure
...
New : structure
...
structure scalar
structure boolean
boolean value true
structure byte
byte value 0
structure long
long value 0
structure double
double value 5
structure string
string value
...
mrk> pvput PVRBigRecord scalar='{"string":{"value":"Hi"}}' scalarArray='{"string":{"value":["aa","bb"]}}'
Old : structure
...
New : structure
time_t timeStamp 2019-04-16 09:46:50.379
long secondsPastEpoch 1555422410
int nanoseconds 379367681
int userTag 0
structure scalar
structure boolean
boolean value true
structure byte
byte value 0
structure long
long value 0
structure double
double value 5
structure string
string value Hi
structure scalarArray
structure boolean
boolean[] value []
structure byte
byte[] value []
structure long
long[] value []
structure double
double[] value []
structure string
string[] value ["aa", "bb"]
structure[] structureArray
union restrictedUnion
(none)
any variantUnion
(none)
mrk> pvput PVRBigRecord '{"structureArray":[{"name":"marty","value":"Kraimer"},{"name":"bob","value":"Dalesio"}]}'
Old : structure
...
New : structure
...
structure[] structureArray
structure
string name marty
string value Kraimer
structure
string name bob
string value Dalesio
union restrictedUnion
(none)
any variantUnion
(none)
一个使用数组过滤器的示例:
mrk> pvget PVRdoubleArray
PVRdoubleArray 2019-04-16 13:55:38.384 [1,2,3,4,5,6,7,8,9,10]
mrk> pvput -r "value[array=1:3]" PVRdoubleArray [100,200,300]
Old : [2,3,4]
New : [100,200,300]
mrk> pvget PVRdoubleArray
PVRdoubleArray 2019-04-16 13:57:02.736 [1,100,200,300,5,6,7,8,9,10]
mrk> pvput DBRdoubleArray [1,2,3,4,5]
Old : 2021-05-07 10:20:22.373 [1,2,3,4,5]
New : 2021-05-07 10:22:07.437 [1,2,3,4,5]
mrk> pvget DBRdoubleArray.[2:3]
DBRdoubleArray.[2:3] 2021-05-07 10:22:07.437 [3,4]