So I had to investigate what is going on. It turns out that when we now initialize a dataNode, we now get a BadTypeMismatch error causing the initialization of dataNodes to fail! Because we have not modified our source code involved, I suspect that something in the SDK has changed regarding this, since the only change we have made is to upgrade the C++ Server SDK to v1.8.5. This feels a bit scary.
So, this is how we initialize our dataNodes:
Code: Select all
statusCode = OpcUa_BadWaitingForInitialData;
value = 0.0;
UaVariant varval;
varval.setDouble(value);
UaDataValue dataValue;
dataValue.setValue(varval, OpcUa_True, OpcUa_True);
dataValue.setStatusCode(statusCode);
dataNode->setValue(NULL, dataValue, OpcUa_False);
Code: Select all
if (OpcUa_IsBad(dataValue.statusCode()) && pNewValue->Datatype != OpcUaType_Null)
{
ret = OpcUa_BadTypeMismatch;
}
And this has the effect that the dataNode is not updated, hence we can quite surprisingly no longer initialize the dataNodes like we previously could!
Fortunately, I've found a work-around, which simply is to check if, and only if the statusCode isn't Bad, we set the data. Otherwise the data type and its value will automatically become null:
Code: Select all
UaVariant varval;
if (OpcUa_IsNotBad(statusCode))
{
varval.setDouble(value);
}
UaDataValue dataValue;
dataValue.setValue(varval, OpcUa_True, OpcUa_True);
dataValue.setStatusCode(statusCode);
dataNode->setValue(NULL, dataValue, OpcUa_False);
I now see that the changelog in v1.8.5 mentions that:
UaVariable - Fix method checkAttributesForWrite to allow writing NULL values if DataType is BaseDataType.
Well, this is what I have observed I guess. What changelog does not mention is the behaviour changes I described above. It would be really nice if you care to explain this change in more detail, for example, shall it no longer be possible to set Bad status and last known data?
Regards,
/Tommy