Force Ignition tag to bad quality and null or False value

I have a driver module. It implements the Device

When I disable the device or delete the device, I would like to pass all tags to BAD Quality and to set valeur of Boolean tags to False ou Integer tags to 0.

I don’t find How I can find the BuiltinDataType from item.getReadValueId() or from node.getUaVariableNode() to adjust the right value

```

public void shutdown() {
logger.info("shutdown()");

subscriptionModel.shutdown();

deviceContext.getSubscriptionModel()
		.getDataItems(deviceContext.getName())
		.forEach(item ->
			{
				String name = deviceContext.getName();

				String identifier = item.getReadValueId().getNodeId().getIdentifier().toString();
				logger.info("getIdentifier()={}",identifier);
				identifier = identifier.replace(String.format("[%s]",name),"");
				// Dynamic Nodes
				DynamicNode node = dynamicNodeManager.findNode(identifier);
				if (node != null){

					// logger.info("node.getUaVariableNode().getDataType()={}",node.getUaVariableNode().getDataType().getType().toString());

					if (node.getUaVariableNode().getDataType().equals(BuiltinDataType.Boolean)){
						item.setValue(new DataValue(new Variant(false),StatusCode.BAD));
					} else {
						item.setValue(new DataValue(null,StatusCode.BAD));
					}
				} else {
					item.setValue(new DataValue(null,StatusCode.BAD));
				}
			});

// folderManager
dynamicNodeManager.shutdown();
staticNodeManager.shutdown();

// Arrêt de l'ExecutorService
executor.shutdownNow();

logger.debug("end shutdown {}",getName());

}

```

UaVariableNode::getDataType returns the NodeId of the DataType.

You can compare that to BuiltinDataType.Boolean.getNodeId() or use BuiltinDataType.fromNodeId on the DataType and compare directly against BuiltinDataType.Boolean.

FWIW, in terms of OPC UA compliance, it is not allowed that a value accompanies a bad severity StatusCode in a DataValue. You must use something like Uncertain_LastUsableValue like we do.

2 Likes

@Kevin.Herron What is a bit annoying in Designer is the boolean apparence. We don’t have any “red” alert for an invalid quality like for tag other type.

If it was possible to have the checkbox border red if tag quality is not Good…

1 Like

I opened a ticket about that 4 years ago :upside_down_face:

4 Likes