Skip to content

Commit 44599a9

Browse files
committed
Adding feature to CA provider to be able to do "valueAlarm" requests.
1 parent 669b241 commit 44599a9

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ else if(!subField.equals("value")) {
381381
}
382382
}
383383
String properties = "timeStamp,alarm";
384-
if(extraProperties) properties += ",display,control";
384+
if(extraProperties) properties += ",display,control,valueAlarm";
385385
Structure structure = null;
386386
switch(valueType) {
387387
case scalar:

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

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ public PVStructure createPVStructure(PVStructure pvRequest,boolean propertiesAll
166166
if(nativeDBRType!=DBRType.ENUM) {
167167
propertyList.add("display");
168168
propertyList.add("control");
169+
if (nativeDBRType != DBRType.STRING) {
170+
propertyList.add("valueAlarm");
171+
}
169172
}
170173
}
171174
for(int indField = 0; indField<pvFields.length; indField++) {
@@ -186,6 +189,10 @@ public PVStructure createPVStructure(PVStructure pvRequest,boolean propertiesAll
186189
if(propertiesAllowed && nativeDBRType!=DBRType.ENUM) propertyList.add("control");
187190
continue;
188191
}
192+
if(pvField.getFieldName().equals("valueAlarm")) {
193+
if(propertiesAllowed && nativeDBRType!=DBRType.STRING && nativeDBRType!=DBRType.ENUM) propertyList.add("valueAlarm");
194+
continue;
195+
}
189196
if(!pvField.getFieldName().equals("value")) {
190197
String message = pvField.toString() + " name not suported";
191198
v3Channel.message(message, MessageType.error);
@@ -241,6 +248,10 @@ public PVStructure createPVStructure(PVStructure pvRequest,boolean propertiesAll
241248
dbrProperty = DBRProperty.control;
242249
continue;
243250
}
251+
if(propertyName.equals("valueAlarm")&& (dbrProperty.compareTo(DBRProperty.control)<0)) {
252+
dbrProperty = DBRProperty.control;
253+
continue;
254+
}
244255
}
245256
}
246257
Type type = Type.scalar;
@@ -452,6 +463,12 @@ public void toStructure(DBR fromDBR) {
452463
double displayHigh = 0.0;
453464
double controlLow = 0.0;
454465
double controlHigh = 0.0;
466+
467+
double lowAlarmLimit = 0.0;
468+
double lowWarningLimit = 0.0;
469+
double highWarningLimit = 0.0;
470+
double highAlarmLimit = 0.0;
471+
455472
String units = null;
456473
bitSet.clear();
457474
DBRType requestDBRType = fromDBR.getType();
@@ -678,6 +695,12 @@ public void toStructure(DBR fromDBR) {
678695
displayHigh = dbr.getUpperDispLimit().doubleValue();
679696
controlLow = dbr.getLowerCtrlLimit().doubleValue();
680697
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
698+
699+
lowAlarmLimit = dbr.getLowerAlarmLimit().doubleValue();
700+
lowWarningLimit = dbr.getLowerWarningLimit().doubleValue();
701+
highWarningLimit = dbr.getUpperWarningLimit().doubleValue();
702+
highAlarmLimit = dbr.getUpperAlarmLimit().doubleValue();
703+
681704
if(elementCount==1) {
682705
convert.fromByte(pvScalarValue, dbr.getByteValue()[0]);
683706
} else {
@@ -719,7 +742,13 @@ public void toStructure(DBR fromDBR) {
719742
displayLow = dbr.getLowerDispLimit().doubleValue();
720743
displayHigh = dbr.getUpperDispLimit().doubleValue();
721744
controlLow = dbr.getLowerCtrlLimit().doubleValue();
722-
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
745+
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
746+
747+
lowAlarmLimit = dbr.getLowerAlarmLimit().doubleValue();
748+
lowWarningLimit = dbr.getLowerWarningLimit().doubleValue();
749+
highWarningLimit = dbr.getUpperWarningLimit().doubleValue();
750+
highAlarmLimit = dbr.getUpperAlarmLimit().doubleValue();
751+
723752
if(elementCount==1) {
724753
convert.fromShort(pvScalarValue, dbr.getShortValue()[0]);
725754
} else {
@@ -761,7 +790,13 @@ public void toStructure(DBR fromDBR) {
761790
displayLow = dbr.getLowerDispLimit().doubleValue();
762791
displayHigh = dbr.getUpperDispLimit().doubleValue();
763792
controlLow = dbr.getLowerCtrlLimit().doubleValue();
764-
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
793+
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
794+
795+
lowAlarmLimit = dbr.getLowerAlarmLimit().doubleValue();
796+
lowWarningLimit = dbr.getLowerWarningLimit().doubleValue();
797+
highWarningLimit = dbr.getUpperWarningLimit().doubleValue();
798+
highAlarmLimit = dbr.getUpperAlarmLimit().doubleValue();
799+
765800
if(elementCount==1) {
766801
convert.fromInt(pvScalarValue, dbr.getIntValue()[0]);
767802
} else {
@@ -803,7 +838,13 @@ public void toStructure(DBR fromDBR) {
803838
displayLow = dbr.getLowerDispLimit().doubleValue();
804839
displayHigh = dbr.getUpperDispLimit().doubleValue();
805840
controlLow = dbr.getLowerCtrlLimit().doubleValue();
806-
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
841+
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
842+
843+
lowAlarmLimit = dbr.getLowerAlarmLimit().doubleValue();
844+
lowWarningLimit = dbr.getLowerWarningLimit().doubleValue();
845+
highWarningLimit = dbr.getUpperWarningLimit().doubleValue();
846+
highAlarmLimit = dbr.getUpperAlarmLimit().doubleValue();
847+
807848
if(elementCount==1) {
808849
convert.fromFloat(pvScalarValue, dbr.getFloatValue()[0]);
809850
} else {
@@ -846,6 +887,12 @@ public void toStructure(DBR fromDBR) {
846887
displayHigh = dbr.getUpperDispLimit().doubleValue();
847888
controlLow = dbr.getLowerCtrlLimit().doubleValue();
848889
controlHigh = dbr.getUpperCtrlLimit().doubleValue();
890+
891+
lowAlarmLimit = dbr.getLowerAlarmLimit().doubleValue();
892+
lowWarningLimit = dbr.getLowerWarningLimit().doubleValue();
893+
highWarningLimit = dbr.getUpperWarningLimit().doubleValue();
894+
highAlarmLimit = dbr.getUpperAlarmLimit().doubleValue();
895+
849896
if(elementCount==1) {
850897
convert.fromDouble(pvScalarValue, dbr.getDoubleValue()[0]);
851898
} else {
@@ -939,6 +986,25 @@ public void toStructure(DBR fromDBR) {
939986
}
940987
}
941988
}
989+
990+
if (lowAlarmLimit < highAlarmLimit || lowWarningLimit < highWarningLimit) {
991+
pvStructure = this.pvStructure.getStructureField("valueAlarm");
992+
if (pvStructure != null) {
993+
PVDouble pvLowWarning = pvStructure.getDoubleField("lowWarningLimit");
994+
PVDouble pvHighWarning = pvStructure.getDoubleField("highWarningLimit");
995+
if (pvLowWarning != null && pvHighWarning != null) {
996+
pvLowWarning.put(lowWarningLimit);
997+
pvHighWarning.put(highWarningLimit);
998+
}
999+
PVDouble pvLowAlarm = pvStructure.getDoubleField("lowAlarmLimit");
1000+
PVDouble pvHighAlarm = pvStructure.getDoubleField("highAlarmLimit");
1001+
if (pvLowAlarm != null && pvHighAlarm != null) {
1002+
pvLowAlarm.put(lowAlarmLimit);
1003+
pvHighAlarm.put(highAlarmLimit);
1004+
}
1005+
}
1006+
}
1007+
9421008
if(firstGetPVStructure.getAndSet(false)) {
9431009
bitSet.clear();
9441010
bitSet.set(0);

0 commit comments

Comments
 (0)