Using the UA modeler, I have created a small test model to experiment with. The model contains an object that I created called TestNumbers which contains two double variables called num1 and num2. I used the demo server to read the XML representation of this model, which then could easily connect to a client. When the client reads the values for num1 and num2, the values are defaulted to 0.0. I initially wanted to test if I could modify these default values, so I went into tnns_testnumbersbase.cpp ( the abbreviation for the namespace was chosen to be tnns) and changed the following code:
Code: Select all
// Mandatory variable num1
defaultValue.setDouble(4.0); //initially contained 0.0, changed to 4.0
s_pnum1 = new OpcUa::BaseDataVariableType(UaNodeId(tnnsId_TestNumbers_num1, nsTypeIdx), "num1", tnns::NodeManagerTestNumberNameSpace::getTypeNamespace(), defaultValue, 3, pTypeNodeConfig);
s_pnum1->setModellingRuleId(OpcUaId_ModellingRule_Mandatory);
s_pnum1->setValueRank(-1);
addStatus = pTypeNodeConfig->addNodeAndReference(pObjectType, s_pnum1, OpcUaId_HasComponent);
UA_ASSERT(addStatus.isGood());
Thank you.