Experimental Physics and Industrial Control System
|
On 12/05/2016 05:45 PM, Madden, Timothy
J. wrote:
I am getting started with Epics V4.
I am playing with the examples in the Java version of 4.6.
Specifically I am using ExampleDatabase.java.
Say we wish to make PVs that are more than soft PVs. There seems
to be more than one way to
make a PV do something. Example: We put a 1 to an int PV, and
the server writes something to an instrument.
How do we do this? It seems like there are several ways:
1) Use a monitor client like seq does.
2) extend PVRecord and fill in the process() function. Not sure
how to get all the data we need.
3) use this RPC business, extending a PVRecord.
4) What about adding a PVListener to PVRecord? I could not
figure this out. The idea is that PVListener
would make the instrument do something, and we need not extend
PVRecord.
What is the preferred design for making a PV do something in a
server?
If you want client to access your server via channelRPC then 4)
For the client to access your server via channelGet, ... ,
channelPutGet then 2)
4) should not be used by You. It is use by internal implementation
to support returning only fields that change to the client.
For channelRPC look at exampleJava/hellloRPC.
It has both an exampleServer and an exampleClient.
For a client to use channelPutGet look at
exampleJava/examplePutGet
It has both HelloPutGetRecord and HelloPutGetRecord
Note how HelloPutGetRecord
1) creates a PVStructure that has the fields it needs.
2) creates a PVRecord that has the newly created pvStructure as it's
top level PVStructure.
3) implements method process.
Note that channelGet, channelPut, and monitors will also work with
this example.
For example a client could first do a channelPut to cause the record
to process and then a channelGet to get the result.
exampleJava/database also shows how to implement both
HelloPutGetRecord and hellloRPC as part of a database that has other
PVRecords.
You want to
Example: We put a 1 to an int PV, and the
server writes something to an instrument.
Start with HelloPutGetRecord and implement something like
public class ExampleIntRecord extends PVRecord {
private static final FieldCreate fieldCreate =
FieldFactory.getFieldCreate();
private static final PVDataCreate pvDataCreate =
PVDataFactory.getPVDataCreate();
private static final StandardField standardField =
StandardFieldFactory.getStandardField();
private PVInt pvValue;
private PVStructure pvAlarm;
public static PVRecord create(String recordName)
{
NTScalarBuilder ntScalarBuilder = NTScalar.createBuilder();
PVStructure pvStructure = ntScalarBuilder.
value(ScalarType.pvInt).
addAlarm().
addTimeStamp().
createPVStructure();
PVRecord pvRecord = new
ExampleIntRecord(recordName,pvDataCreate.createPVStructure(structure));
PVDatabase master = PVDatabaseFactory.getMaster();
master.addRecord(pvRecord);
return pvRecord;
}
private ExampleIntRecord(String recordName,PVStructure
pvStructure) {
super(recordName,pvStructure);
pvValue = pvStructure.getSubField(PVInt.class, "value");
if(pvValue==null) throw new IllegalArgumentException("value
not found");
pvAlarm = pvStructure.getSubField(PVStructure.class,
"alarm");
if(pvAlarm==null) throw new IllegalArgumentException("alarm
not found");
}
public void process()
{
int value = pvValue.get();
// You do something with value !!!
super.process();
}
}
Note that You can use the alarm field to report problem if the
client send a bad value.
General question:
I know RPC stanhs for remote procedure call, but what does it
mean in epics V4?
channelPutGet and channelRPC both implement a remote procedure call
where all data is passed as PVData.
For both the client sends a PVStructure to the server.
The server processes the request and returns the result via a
PVStructure.
For a channelRPC there is no actual PVRecord that can be accessed
via channelGet, ..., monitor.
For channelPutGet there is a PVRecord with a PVStructure with the
introspection interface
structure
argument
...
result
...
...
The client sends data that matches argument and the server returns
data that matches result.
Other client can get and put and monitor data in the PVRecord.
Marty
What does it do that epics V3 does not do? Is this just a fancy
name for record support?
Tim Madden
APS, Argonne
|
- References:
- Epics V4 Questions - New to Epics 4 Madden, Timothy J.
- Navigate by Date:
- Prev:
RE: deadlock in pcas 3.14.12.6-rc1 Wang Xiaoqiang (PSI)
- Next:
RE: streamdevice 2.7.7 and PINI Mark Rivers
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
<2016>
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Epics V4 Questions - New to Epics 4 Andrew Johnson
- Next:
Re: Epics V4 Questions - New to Epics 4 Ralph Lange
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
<2016>
2017
2018
2019
2020
2021
2022
2023
2024
|
ANJ, 06 Dec 2016 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
·
Search
·
EPICS V4
·
IRMIS
·
Talk
·
Bugs
·
Documents
·
Links
·
Licensing
·
|