GeezerVison is showing github.com — exampleLink now has get, put, and monitor; exampleClient/HelloWorldRP… · epics-base/exampleJava@13ac379
File treeExpand file treeCollapse file tree Open diff view settings exampleClient/src/org/epics/exampleClient exampleLink/src/org/epics/exampleJava/exampleLink
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: exampleClient/src/org/epics/exampleClient/HelloWorldRPC.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -82,7 +82,7 @@ static void exampleMore(PvaClient pva,String channelName) | 82 | 82 | createStructure(); | 83 | 83 | PVStructure pvRequest = pvDataCreate.createPVStructure(topStructure); | 84 | 84 | PVString pvArgument = pvRequest.getSubField(PVString.class,"value"); | 85 | | - PvaClientRPC rpc = pva.channel(channelName).createRPC(pvRequest); | | 85 | + PvaClientRPC rpc = pva.channel(channelName).createRPC(); | 86 | 86 | pvArgument.put("World"); | 87 | 87 | System.out.println("send " + pvArgument.get()); | 88 | 88 | PVStructure pvResult = rpc.request(pvRequest); | @@ -106,7 +106,7 @@ static void exampleEvenMore(PvaClient pva,String channelName) | 106 | 106 | Status status = pvaChannel.waitConnect(2.0); | 107 | 107 | if(!status.isOK()) {System.out.println(" connect failed"); return;} | 108 | 108 | ClientRPCRequester requester = new ClientRPCRequester(); | 109 | | - PvaClientRPC rpc = pvaChannel.createRPC(pvRequest); | | 109 | + PvaClientRPC rpc = pvaChannel.createRPC(); | 110 | 110 | rpc.issueConnect(); | 111 | 111 | status = rpc.waitConnect(); | 112 | 112 | if(!status.isOK()) {System.out.println(" rpc connect failed"); return;} | |
Collapse file Copy file name to clipboard +62Lines changed: 62 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/** | | 2 | + * Copyright - See the COPYRIGHT that is included with this distribution. | | 3 | + * EPICS pvData is distributed subject to a Software License Agreement found | | 4 | + * in file LICENSE that is included with this distribution. | | 5 | + */ | | 6 | + | | 7 | +package org.epics.exampleJava.exampleLink; | | 8 | + | | 9 | +import org.epics.pvaClient.*; | | 10 | +import org.epics.pvaClient.PvaClientChannel; | | 11 | +import org.epics.pvaClient.PvaClientMonitor; | | 12 | +import org.epics.pvaClient.PvaClientMonitorRequester; | | 13 | +import org.epics.pvdata.factory.ConvertFactory; | | 14 | +import org.epics.pvdata.factory.StandardPVFieldFactory; | | 15 | +import org.epics.pvdata.pv.Convert; | | 16 | +import org.epics.pvdata.pv.PVDoubleArray; | | 17 | +import org.epics.pvdata.pv.PVStructure; | | 18 | +import org.epics.pvdata.pv.ScalarType; | | 19 | +import org.epics.pvdata.pv.StandardPVField; | | 20 | +import org.epics.pvdatabase.PVRecord; | | 21 | + | | 22 | +public class ExampleGetLinkRecord extends PVRecord | | 23 | +{ | | 24 | + private static final StandardPVField standardPVField = StandardPVFieldFactory.getStandardPVField(); | | 25 | + | | 26 | + private PVDoubleArray pvValue = null; | | 27 | + private PvaClientGet pvaClientGet = null; | | 28 | + | | 29 | + public static PVRecord create(PvaClient pva,String recordName,String provider,String channelName) | | 30 | + { | | 31 | + PVStructure pvStructure = standardPVField.scalarArray(ScalarType.pvDouble, "timeStamp"); | | 32 | + ExampleGetLinkRecord pvRecord = new ExampleGetLinkRecord(recordName,pvStructure); | | 33 | + if(!pvRecord.init(pva,channelName,provider)) return null; | | 34 | + return pvRecord; | | 35 | + } | | 36 | + public ExampleGetLinkRecord(String recordName,PVStructure pvStructure) | | 37 | + { | | 38 | + super(recordName,pvStructure); | | 39 | + } | | 40 | + | | 41 | + private boolean init(PvaClient pva,String channelName,String provider) | | 42 | + { | | 43 | + PVStructure pvStructure = getPVRecordStructure().getPVStructure(); | | 44 | + pvValue = pvStructure.getSubField(PVDoubleArray.class,"value"); | | 45 | + if(pvValue == null) { | | 46 | + return false; | | 47 | + } | | 48 | + pvaClientGet = pva.channel(channelName,provider).createGet(); | | 49 | + return true; | | 50 | + } | | 51 | + | | 52 | + | | 53 | + public void process() | | 54 | + { | | 55 | + pvaClientGet.get(); | | 56 | + double[] value = pvaClientGet.getData().getDoubleArray(); | | 57 | + int length = value.length; | | 58 | + pvValue.put(0, length, value, 0); | | 59 | + super.process(); | | 60 | + } | | 61 | + | | 62 | +} |
Collapse file Copy file name to clipboardExpand all lines: exampleLink/src/org/epics/exampleJava/exampleLink/ExampleLinkMain.java +13-8Lines changed: 13 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,20 +35,18 @@ public static void main(String[] args) | 35 | 35 | { | 36 | 36 | int argc = args.length; | 37 | 37 | String provider = "pva"; | 38 | | - String exampleLinkRecordName = "exampleLink"; | 39 | 38 | String linkedRecordName = "doubleArray"; | 40 | 39 | boolean generateLinkedRecord = true; | 41 | 40 | if(argc==1 && args[0].endsWith("-help")) { | 42 | | - System.out.println("provider exampleLinkRecordName linkedRecordName generateLinkedRecord"); | | 41 | + System.out.println("provider linkedRecordName generateLinkedRecord"); | 43 | 42 | System.out.println("default"); | 44 | | - System.out.println(provider + " " + exampleLinkRecordName + " " + linkedRecordName + " " + generateLinkedRecord); | | 43 | + System.out.println(provider + " " + linkedRecordName + " " + generateLinkedRecord); | 45 | 44 | System.exit(0); | 46 | 45 | } | 47 | 46 | if(argc>0) provider = args[0]; | 48 | | - if(argc>1) exampleLinkRecordName = args[1]; | 49 | | - if(argc>2) linkedRecordName = args[2]; | 50 | | - if(argc>3) { | 51 | | - String val = args[3]; | | 47 | + if(argc>1) linkedRecordName = args[1]; | | 48 | + if(argc>2) { | | 49 | + String val = args[2]; | 52 | 50 | if(val.equals("false")) generateLinkedRecord = false; | 53 | 51 | } | 54 | 52 | try { | @@ -66,7 +64,14 @@ public static void main(String[] args) | 66 | 64 | } | 67 | 65 | ServerContextImpl context = ServerContextImpl.startPVAServer("local",0,true,System.out); | 68 | 66 | PvaClient pva= PvaClient.get(provider); | 69 | | - PVRecord pvRecord = ExampleLinkRecord.create(pva,exampleLinkRecordName,provider,linkedRecordName); | | 67 | + PVRecord pvRecord = ExampleMonitorLinkRecord.create( | | 68 | + pva,"exampleMonitorLink",provider,linkedRecordName); | | 69 | + master.addRecord(pvRecord); | | 70 | + pvRecord = ExampleGetLinkRecord.create( | | 71 | + pva,"exampleGetLink",provider,linkedRecordName); | | 72 | + master.addRecord(pvRecord); | | 73 | + pvRecord = ExamplePutLinkRecord.create( | | 74 | + pva,"examplePutLink",provider,linkedRecordName); | 70 | 75 | master.addRecord(pvRecord); | 71 | 76 | while(true) { | 72 | 77 | System.out.print("waiting for exit: "); | |
Collapse file Copy file name to clipboardExpand all lines: exampleLink/src/org/epics/exampleJava/exampleLink/ExampleMonitorLinkRecord.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 19 | 19 | import org.epics.pvdata.pv.StandardPVField; | 20 | 20 | import org.epics.pvdatabase.PVRecord; | 21 | 21 |
| 22 | | -public class ExampleLinkRecord extends PVRecord | | 22 | +public class ExampleMonitorLinkRecord extends PVRecord | 23 | 23 | implements PvaClientMonitorRequester | 24 | 24 | { | 25 | 25 | private static final StandardPVField standardPVField = StandardPVFieldFactory.getStandardPVField(); | @@ -30,11 +30,11 @@ public class ExampleLinkRecord extends PVRecord | 30 | 30 | public static PVRecord create(PvaClient pva,String recordName,String provider,String channelName) | 31 | 31 | { | 32 | 32 | PVStructure pvStructure = standardPVField.scalarArray(ScalarType.pvDouble, "timeStamp"); | 33 | | - ExampleLinkRecord pvRecord = new ExampleLinkRecord(recordName,pvStructure); | | 33 | + ExampleMonitorLinkRecord pvRecord = new ExampleMonitorLinkRecord(recordName,pvStructure); | 34 | 34 | if(!pvRecord.init(pva,channelName,provider)) return null; | 35 | 35 | return pvRecord; | 36 | 36 | } | 37 | | - public ExampleLinkRecord(String recordName,PVStructure pvStructure) | | 37 | + public ExampleMonitorLinkRecord(String recordName,PVStructure pvStructure) | 38 | 38 | { | 39 | 39 | super(recordName,pvStructure); | 40 | 40 | } | |
Collapse file Copy file name to clipboard +62Lines changed: 62 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/** | | 2 | + * Copyright - See the COPYRIGHT that is included with this distribution. | | 3 | + * EPICS pvData is distributed subject to a Software License Agreement found | | 4 | + * in file LICENSE that is included with this distribution. | | 5 | + */ | | 6 | + | | 7 | +package org.epics.exampleJava.exampleLink; | | 8 | + | | 9 | +import org.epics.pvaClient.*; | | 10 | +import org.epics.pvaClient.PvaClientChannel; | | 11 | +import org.epics.pvaClient.PvaClientMonitor; | | 12 | +import org.epics.pvaClient.PvaClientMonitorRequester; | | 13 | +import org.epics.pvdata.factory.ConvertFactory; | | 14 | +import org.epics.pvdata.factory.StandardPVFieldFactory; | | 15 | +import org.epics.pvdata.pv.Convert; | | 16 | +import org.epics.pvdata.pv.PVDoubleArray; | | 17 | +import org.epics.pvdata.pv.PVStructure; | | 18 | +import org.epics.pvdata.pv.ScalarType; | | 19 | +import org.epics.pvdata.pv.StandardPVField; | | 20 | +import org.epics.pvdatabase.PVRecord; | | 21 | + | | 22 | +public class ExamplePutLinkRecord extends PVRecord | | 23 | +{ | | 24 | + private static final StandardPVField standardPVField = StandardPVFieldFactory.getStandardPVField(); | | 25 | + private static Convert convert = ConvertFactory.getConvert(); | | 26 | + | | 27 | + | | 28 | + private PVDoubleArray pvValue = null; | | 29 | + private PvaClientPut pvaClientPut = null; | | 30 | + | | 31 | + public static PVRecord create(PvaClient pva,String recordName,String provider,String channelName) | | 32 | + { | | 33 | + PVStructure pvStructure = standardPVField.scalarArray(ScalarType.pvDouble, "timeStamp"); | | 34 | + ExamplePutLinkRecord pvRecord = new ExamplePutLinkRecord(recordName,pvStructure); | | 35 | + if(!pvRecord.init(pva,channelName,provider)) return null; | | 36 | + return pvRecord; | | 37 | + } | | 38 | + public ExamplePutLinkRecord(String recordName,PVStructure pvStructure) | | 39 | + { | | 40 | + super(recordName,pvStructure); | | 41 | + } | | 42 | + | | 43 | + private boolean init(PvaClient pva,String channelName,String provider) | | 44 | + { | | 45 | + PVStructure pvStructure = getPVRecordStructure().getPVStructure(); | | 46 | + pvValue = pvStructure.getSubField(PVDoubleArray.class,"value"); | | 47 | + if(pvValue == null) { | | 48 | + return false; | | 49 | + } | | 50 | + pvaClientPut = pva.channel(channelName,provider).createPut(); | | 51 | + return true; | | 52 | + } | | 53 | + | | 54 | + | | 55 | + public void process() | | 56 | + { | | 57 | + convert.copy(pvValue,pvaClientPut.getData().getValue()); | | 58 | + pvaClientPut.put(); | | 59 | + super.process(); | | 60 | + } | | 61 | + | | 62 | +} |
|