Skip to content

Commit 802a4b2

Browse files
committed
add StatusCode values
1 parent 50c2088 commit 802a4b2

File tree

5 files changed

+54
-1
lines changed

5 files changed

+54
-1
lines changed

examples/prosys/opc30200/src/main/java/com/connectedcooking/opcua/dynamicnodemanager/examples/prosys/opc30200/ProsysOpc30200Server.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.connectedcooking.opcua.dynamicnodemanager.adaptor.prosys.ProsysDynNodeManagerAdaptor;
44
import com.connectedcooking.opcua.dynamicnodemanager.core.DynNodeManager;
5+
import com.connectedcooking.opcua.dynamicnodemanager.core.DynResponse;
56
import com.connectedcooking.opcua.dynamicnodemanager.core.RealNodeId;
67
import com.connectedcooking.opcua.dynamicnodemanager.core.datatype.DynLocalizedText;
78
import com.connectedcooking.opcua.dynamicnodemanager.examples.prosys.opc30200.model.cke.server.CommercialKitchenEquipmentServerInformationModel;
@@ -194,6 +195,12 @@ private void initialize() throws Exception {
194195
errorId -> new RealNodeId(errorConditions.realNodeId(deviceId), "Error_" + errorId)).collect(toList()))
195196
.registerAndGet();
196197

198+
dynNodeManager.nodeBuilder()
199+
.childVariable("Quality")
200+
.asComponent(error)
201+
.value(DynResponse.StatusCodes.Uncertain)
202+
.register();
203+
197204
dynNodeManager.nodeBuilder()
198205
.childVariable("ActiveState")
199206
.asComponent(error)

examples/prosys/opc30200/src/test/java/com/connectedcooking/opcua/dynamicnodemanager/examples/prosys/opc30200/ProsysOpc30200ServerITTest.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ void ErrorConditions_Error_references() throws Exception {
721721
assertThat(containsReference(ReferenceTypeIds.HasComponent, new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/ActiveState"), new NodeId(0, 63), references)).isTrue();
722722
assertThat(containsReference(ReferenceTypeIds.HasProperty, new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/InputNode"), new NodeId(0, 68), references)).isTrue();
723723
assertThat(containsReference(ReferenceTypeIds.HasProperty, new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/SuppressedOrShelved"), new NodeId(0, 68), references)).isTrue();
724+
assertThat(containsReference(ReferenceTypeIds.HasComponent, new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/Quality"), new NodeId(0, 63), references)).isTrue();
724725
}
725726

726727
@Test
@@ -742,6 +743,43 @@ void ErrorConditions_Error_attributes() throws Exception {
742743
);
743744
}
744745

746+
@Test
747+
void ErrorConditions_Error_Quality_TypeDefinition() throws Exception {
748+
var typeDefinition = client.getAddressSpace().getTypeDefinition(new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/Quality"));
749+
750+
assertThat(typeDefinition).isEqualTo(new ExpandedNodeId(new NodeId(0, 63)));
751+
}
752+
753+
@Test
754+
void ErrorConditions_Error_Quality_references() throws Exception {
755+
var references = client.getAddressSpace().browse(new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/Quality"));
756+
757+
assertThat(references).isEmpty();
758+
}
759+
760+
@Test
761+
void ErrorConditions_Error_Quality_attributes() throws Exception {
762+
var browseId = new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/Quality");
763+
764+
var nodeId = client.readAttribute(browseId, Attributes.NodeId);
765+
var nodeClass = client.readAttribute(browseId, Attributes.NodeClass);
766+
var browseName = client.readAttribute(browseId, Attributes.BrowseName);
767+
var displayName = client.readAttribute(browseId, Attributes.DisplayName);
768+
var description = client.readAttribute(browseId, Attributes.Description);
769+
var dataType = client.readAttribute(browseId, Attributes.DataType);
770+
var value = client.readAttribute(browseId, Attributes.Value);
771+
772+
assertAll(
773+
() -> assertThat(nodeId.getValue().getValue()).isEqualTo(browseId),
774+
() -> assertThat(nodeClass.getValue().getValue()).isEqualTo(NodeClass.Variable.getValue()),
775+
() -> assertThat(((QualifiedName) browseName.getValue().getValue()).getName()).isEqualTo("Quality"),
776+
() -> assertThat(((LocalizedText) displayName.getValue().getValue()).getText()).isEqualTo("Quality"),
777+
() -> assertThat(((LocalizedText) description.getValue().getValue()).getText()).isEqualTo(""),
778+
() -> assertThat(dataType.getValue().getValue()).isEqualTo(DataTypeIdentifiers.StatusCode),
779+
() -> assertThat(value.getValue().getValue()).isEqualTo(StatusCodes.Uncertain)
780+
);
781+
}
782+
745783
@Test
746784
void ErrorConditions_Error_ActiveState_TypeDefinition() throws Exception {
747785
var typeDefinition = client.getAddressSpace().getTypeDefinition(new NodeId(NS, "CombiSteamerDevice_1/ErrorConditions/Error_801/ActiveState"));

src/main/java/com/connectedcooking/opcua/dynamicnodemanager/adaptor/prosys/ProsysDynNodeManagerAdaptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,9 @@ private Object convertValueToStandard(Object value) {
662662
if (value instanceof RealNodeId) {
663663
return TypeUtils.toNodeId((RealNodeId) value, namespaceIndex);
664664
}
665+
if (value instanceof DynResponse.StatusCodes) {
666+
return TypeUtils.toStatusCode((DynResponse.StatusCodes) value);
667+
}
665668
return value;
666669
}
667670
}

src/main/java/com/connectedcooking/opcua/dynamicnodemanager/adaptor/prosys/TypeUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ static UnsignedInteger toStatusCode(DynResponse.StatusCodes status) {
281281
return StatusCodes.Bad_NotSupported;
282282
case Bad_NotImplemented:
283283
return StatusCodes.Bad_NotImplemented;
284+
case Uncertain:
285+
return StatusCodes.Uncertain;
284286
}
285287
return StatusCodes.Bad;
286288
}
@@ -352,6 +354,8 @@ static RealNodeId guessValueDataType(Object value) {
352354
return BasicValueDataTypes.NodeId;
353355
} else if (value instanceof ExpandedNodeId) {
354356
return BasicValueDataTypes.ExpandedNodeId;
357+
} else if (value instanceof DynResponse.StatusCodes) {
358+
return BasicValueDataTypes.StatusCode;
355359
}
356360
return null;
357361
}

src/main/java/com/connectedcooking/opcua/dynamicnodemanager/core/DynResponse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public enum StatusCodes {
2222
Bad_AttributeIdInvalid,
2323
Bad_NotFound,
2424
Bad_NotSupported,
25-
Bad_NotImplemented;
25+
Bad_NotImplemented,
26+
Uncertain;
2627

2728
/**
2829
* Indicates whether the response is successful.

0 commit comments

Comments
 (0)