Code: Select all
internal class TestServerManager : ServerManager
{
protected override void OnRootNodeManagerStarted(RootNodeManager nodeManager)
{
BaseNodeManager nm = new TestNodeManager(this);
nm.Startup();
}
}
internal partial class TestNodeManager : BaseNodeManager
{
public override void Startup()
{
ImportUaNodeset(new FileInfo(GetNodeSetPath()));
}
}
Code: Select all
serverManager.Stop();
serverManager.Start();
I tried directly deleting the root node, reloading the model and notifying the client about the change. But although the client received the notification of the change, the NodeSet did not update. The code is as follows:
Code: Select all
public void ImportUaNodesetAndNotify(FileInfo istrm)
{
ClearAllNodes();
ImportUaNodeset(istrm);
ReportModelChangeEvent();
}
private void ClearAllNodes()
{
// delete root node
NodeId rootFolderId = UnifiedAutomation.UaBase.ObjectIds.RootFolder;
DeleteNode(Server.DefaultRequestContext, rootFolderId, true);
}
private void ReportModelChangeEvent()
{
// Create a ModelChange event
var modelChangeEvent = new GenericEvent(Server.FilterManager);
modelChangeEvent.Initialize(
eventId: null,
eventType: UnifiedAutomation.UaBase.ObjectTypeIds.GeneralModelChangeEventType,
sourceNode: UnifiedAutomation.UaBase.ObjectIds.Server,
sourceName: "Server",
severity: EventSeverity.Low,
message: new LocalizedText("The address space has changed.")
);
var changes = new List<ModelChangeStructureDataType>
{
new ModelChangeStructureDataType
{
Affected = UnifiedAutomation.UaBase.ObjectIds.Server,
AffectedType = UnifiedAutomation.UaBase.ObjectTypeIds.BaseObjectType
}
};
Server.ReportEvent(UnifiedAutomation.UaBase.ObjectIds.Server, modelChangeEvent);
}