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 | 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 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Epics V4 Questions - New to Epics 4 |
From: | Marty Kraimer <[email protected]> |
To: | [email protected] |
Date: | Tue, 6 Dec 2016 07:08:57 -0500 |
On 12/05/2016 05:45 PM, Madden, Timothy
J. wrote:
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.
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
|