Skip to content

Commit 1196db5

Browse files
committed
For provider ca channelPut now implement put with and without callback.
The default is no callback. This is just like ca provider for pvAccessCPP and for qsrv from pva2pva.
1 parent 825debc commit 1196db5

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

pvAccessJava/src/org/epics/ca/BaseV3ChannelPut.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class BaseV3ChannelPut
8686
private final AtomicBoolean isGetActive = new AtomicBoolean(false);
8787

8888
private final PVStructure pvRequest;
89+
private boolean block = false;
8990

9091
/**
9192
* Constructor.
@@ -119,6 +120,11 @@ public BaseV3ChannelPut(ChannelPutRequester channelPutRequester,
119120

120121
protected void initializePut()
121122
{
123+
PVString pvString = pvRequest.getSubField(PVString.class,"record._options.block");
124+
if(pvString!=null) {
125+
String value = pvString.get();
126+
if(value.equals("true")) block = true;
127+
}
122128
if(v3ChannelStructure.createPVStructure(pvRequest,true)==null) {
123129
elementCount = 1;
124130
channelPutRequester.channelPutConnect(createChannelStructureStatus,this,null);
@@ -231,89 +237,89 @@ public void put(PVStructure pvPutStructure, BitSet bitSet) {
231237
channelPutRequester.putDone(statusCreate.createStatus(StatusType.ERROR, "invalid bitSet, only value can be put for CA", null), this);
232238
return;
233239
}
234-
240+
PutListener callback = (block ? this : null);
235241
isActive.set(true);
236242
try {
237243
if(pvIndex!=null) {
238244
short index = (short)pvIndex.get();
239-
jcaChannel.put(index, this);
245+
jcaChannel.put(index, callback);
240246
} else if(nativeDBRType==DBRType.BYTE) {
241247
if(elementCount==1) {
242248
PVByte pvFrom = (PVByte)pvField;
243249
byte from = pvFrom.get();
244-
jcaChannel.put(from, this);
250+
jcaChannel.put(from, callback);
245251
} else {
246252
PVByteArray fromArray =(PVByteArray)pvField;
247253
int len = fromArray.get(0, elementCount, byteArrayData);
248254
byte[] from = byteArrayData.data;
249255
int capacity = fromArray.getCapacity();
250256
for (int i=len; i<capacity; i++) from[i] = 0;
251-
jcaChannel.put(from, this);
257+
jcaChannel.put(from, callback);
252258
}
253259
} else if(nativeDBRType==DBRType.SHORT) {
254260
if(elementCount==1) {
255261
PVShort pvFrom = (PVShort)pvField;
256262
short from = pvFrom.get();
257-
jcaChannel.put(from, this);
263+
jcaChannel.put(from, callback);
258264
} else {
259265
PVShortArray fromArray =(PVShortArray)pvField;
260266
int len = fromArray.get(0, elementCount, shortArrayData);
261267
short[] from = shortArrayData.data;
262268
int capacity = fromArray.getCapacity();
263269
for (int i=len; i<capacity; i++) from[i] = 0;
264-
jcaChannel.put(from, this);
270+
jcaChannel.put(from, callback);
265271
}
266272
} else if(nativeDBRType==DBRType.INT) {
267273
if(elementCount==1) {
268274
PVInt pvFrom = (PVInt)pvField;
269275
int from = pvFrom.get();
270-
jcaChannel.put(from, this);
276+
jcaChannel.put(from, callback);
271277
} else {
272278
PVIntArray fromArray =(PVIntArray)pvField;
273279
int len = fromArray.get(0, elementCount, intArrayData);
274280
int[] from = intArrayData.data;
275281
int capacity = fromArray.getCapacity();
276282
for (int i=len; i<capacity; i++) from[i] = 0;
277-
jcaChannel.put(from, this);
283+
jcaChannel.put(from, callback);
278284
}
279285
} else if(nativeDBRType==DBRType.FLOAT) {
280286
if(elementCount==1) {
281287
PVFloat pvFrom = (PVFloat)pvField;
282288
float from = pvFrom.get();
283-
jcaChannel.put(from, this);
289+
jcaChannel.put(from, callback);
284290
} else {
285291
PVFloatArray fromArray =(PVFloatArray)pvField;
286292
int len = fromArray.get(0, elementCount, floatArrayData);
287293
float[] from = floatArrayData.data;
288294
int capacity = fromArray.getCapacity();
289295
for (int i=len; i<capacity; i++) from[i] = 0;
290-
jcaChannel.put(from, this);
296+
jcaChannel.put(from, callback);
291297
}
292298
} else if(nativeDBRType==DBRType.DOUBLE) {
293299
if(elementCount==1) {
294300
PVDouble pvFrom = (PVDouble)pvField;
295301
double from = pvFrom.get();
296-
jcaChannel.put(from, this);
302+
jcaChannel.put(from, callback);
297303
} else {
298304
PVDoubleArray fromArray =(PVDoubleArray)pvField;
299305
int len = fromArray.get(0, elementCount, doubleArrayData);
300306
double[] from = doubleArrayData.data;
301307
int capacity = fromArray.getCapacity();
302308
for (int i=len; i<capacity; i++) from[i] = 0;
303-
jcaChannel.put(from, this);
309+
jcaChannel.put(from, callback);
304310
}
305311
} else if(nativeDBRType==DBRType.STRING) {
306312
if(elementCount==1) {
307313
PVString pvFrom = (PVString)pvField;
308314
String from = pvFrom.get();
309-
jcaChannel.put(from, this);
315+
jcaChannel.put(from, callback);
310316
} else {
311317
PVStringArray fromArray =(PVStringArray)pvField;
312318
int len = fromArray.get(0, elementCount, stringArrayData);
313319
String[] from = stringArrayData.data;
314320
int capacity = fromArray.getCapacity();
315321
for (int i=len; i<capacity; i++) from[i] = "";
316-
jcaChannel.put(from, this);
322+
jcaChannel.put(from, callback);
317323
}
318324
} else {
319325
throw new IllegalArgumentException("unknown DBRType " + nativeDBRType.getName());
@@ -322,6 +328,9 @@ public void put(PVStructure pvPutStructure, BitSet bitSet) {
322328
putDone(statusCreate.createStatus(StatusType.ERROR, "failed to put", th));
323329
return;
324330
}
331+
if(!block) {
332+
putDone(okStatus);
333+
}
325334
}
326335

327336
/* (non-Javadoc)

0 commit comments

Comments
 (0)