public virtual void Initialise(CustomNodeManager2 nodeManager) { ApplicationNodeManager = nodeManager; if (string.IsNullOrEmpty(ResourcePath)) { return; } NamespaceUris = new List <string>(); NodeStateCollection predefinedNodeStateCollection = new NodeStateCollection(); Stream stream = new FileStream(ResourcePath, FileMode.Open); UANodeSet uaNodeSet = UANodeSet.Read(stream); NamespaceUris.AddRange(ApplicationNodeManager.NamespaceUris); // Update namespace table if (uaNodeSet.NamespaceUris != null) { foreach (string namespaceUri in uaNodeSet.NamespaceUris) { NamespaceUris.Add(namespaceUri); ApplicationNodeManager.SystemContext.NamespaceUris.GetIndexOrAppend(namespaceUri); } } // Update server table if (uaNodeSet.ServerUris != null) { foreach (string serverUri in uaNodeSet.ServerUris) { ServerUris.Add(serverUri); ApplicationNodeManager.SystemContext.ServerUris.GetIndexOrAppend(serverUri); } } uaNodeSet.Import(ApplicationNodeManager.SystemContext, predefinedNodeStateCollection); NodeStateCollection = predefinedNodeStateCollection; }
/// <summary> /// Creates a refrigerator factory /// </summary> /// <param name="parentNode">The node that should old the refrigerators</param> /// <param name="refrigeratorName">The name for the new refrigerator</param> /// <param name="customManager">The node manager for the nodes created.</param> public RefrigeratorFactory(NodeState parentNode, string refrigeratorName, CustomNodeManager2 customManager) { m_refrigeratorName = refrigeratorName; m_namespaceindex = customManager.NamespaceIndex; m_systemContext = customManager.SystemContext; m_nodeFactory = new NodeFactory(customManager); m_parentNode = parentNode; _numGenerator = new Random(); CreateRefrigerator(); }
/// <summary> /// Creates a new boiler for each instantiation of this class /// </summary> /// <param name="parentNode"></param> /// <param name="boilerName"></param> /// <param name="customManager"></param> public BoilerFactory(NodeState parentNode, string boilerName, CustomNodeManager2 customManager, uint count) { m_BoilerName = boilerName; m_namespaceindex = customManager.NamespaceIndex; m_nodeFactory = new NodeFactory(customManager); m_parentNode = parentNode; m_nodeManager = customManager; countBoilers = countBoilers + count; CreateBoiler(); }
/// <summary> /// Initializes the area. /// </summary> public SourceState( CustomNodeManager2 nodeManager, NodeId nodeId, string sourcePath) : base(null) { Initialize(nodeManager.SystemContext); // save the node manager that owns the source. _nodeManager = nodeManager; // create the source with the underlying system. _source = ((UnderlyingSystem)nodeManager.SystemContext.SystemHandle).CreateSource(sourcePath, OnAlarmChanged); // initialize the area with the fixed metadata. SymbolicName = _source.Name; NodeId = nodeId; BrowseName = new QualifiedName(Utils.Format("{0}", _source.Name), nodeId.NamespaceIndex); DisplayName = BrowseName.Name; Description = null; ReferenceTypeId = null; TypeDefinitionId = ObjectTypeIds.BaseObjectType; EventNotifier = EventNotifiers.None; // create a dialog. _dialog = CreateDialog("OnlineState"); // create the table of conditions. _alarms = new Dictionary <string, AlarmConditionState>(); _events = new Dictionary <string, AlarmConditionState>(); _branches = new Dictionary <NodeId, AlarmConditionState>(); // request an updated for all alarms. _source.Refresh(); }
public override void Initialise(CustomNodeManager2 nodeManager) { ApplicationNodeManager = nodeManager; ushort namespaceIndex = ApplicationNodeManager.SystemContext.NamespaceUris.GetIndexOrAppend(NamespaceUris[0]); /* ***************************************** */ /* ControllerType */ /* ***************************************** */ BaseObjectState controller = new BaseObjectState(null) { NodeId = new NodeId("Controllers", namespaceIndex), BrowseName = new QualifiedName("Controllers", namespaceIndex),//Qualified name is very important DisplayName = new LocalizedText("Controllers"), EventNotifier = EventNotifiers.SubscribeToEvents | EventNotifiers.HistoryRead | EventNotifiers.HistoryWrite, TypeDefinitionId = ObjectTypeIds.BaseObjectType, }; controller.AddReference(ReferenceTypeIds.Organizes, true, ObjectIds.ObjectsFolder); //Variables PropertyState <uint> state = new PropertyState <uint>(controller) { NodeId = new NodeId("Controllers.State", namespaceIndex), BrowseName = new QualifiedName("State", namespaceIndex), DisplayName = new LocalizedText("State"), TypeDefinitionId = VariableTypeIds.PropertyType, ReferenceTypeId = ReferenceTypeIds.HasProperty, DataType = DataTypeIds.UInt32, ValueRank = ValueRanks.Scalar, AccessLevel = AccessLevels.CurrentReadOrWrite }; lock (ApplicationNodeManager.Lock) { _stateNode = state; } controller.AddChild(state); //Method MethodState start = new MethodState(controller) { NodeId = new NodeId("Controllers.Start", namespaceIndex), BrowseName = new QualifiedName("Start", namespaceIndex), DisplayName = new LocalizedText("Start"), ReferenceTypeId = ReferenceTypeIds.HasComponent, UserExecutable = true, Executable = true }; //Method - Input start.InputArguments = new PropertyState <Argument[]>(start) { NodeId = new NodeId("Controllers.Start.InputArguments", namespaceIndex), BrowseName = BrowseNames.InputArguments, DisplayName = new LocalizedText(BrowseNames.InputArguments), TypeDefinitionId = VariableTypeIds.PropertyType, ReferenceTypeId = ReferenceTypeIds.HasProperty, DataType = DataTypeIds.Argument, ValueRank = ValueRanks.OneDimension, OnReadUserAccessLevel = OnReadUserAccessLevel, OnSimpleWriteValue = OnWriteValue }; Argument[] inputArguments = new Argument[2]; inputArguments[0] = new Argument { Name = "Initial State", Description = "The initialize state for the process.", DataType = DataTypeIds.UInt32, ValueRank = ValueRanks.Scalar, }; inputArguments[1] = new Argument { Name = "Final State", Description = "The final state for the process.", DataType = DataTypeIds.UInt32, ValueRank = ValueRanks.Scalar }; start.InputArguments.Value = inputArguments; //Method - Output start.OutputArguments = new PropertyState <Argument[]>(start) { NodeId = new NodeId("Controllers.Start.OutputArguments", namespaceIndex), BrowseName = BrowseNames.OutputArguments, TypeDefinitionId = VariableTypeIds.PropertyType, ReferenceTypeId = ReferenceTypeIds.HasProperty, DataType = DataTypeIds.Argument, ValueRank = ValueRanks.OneDimension, OnReadUserAccessLevel = OnReadUserAccessLevel, OnSimpleWriteValue = OnWriteValue, }; start.OutputArguments.DisplayName = start.OutputArguments.BrowseName.Name; Argument[] outputArguments = new Argument[2]; outputArguments[0] = new Argument { Name = "Revised Initial State", Description = "The revised initialize state for the process.", DataType = DataTypeIds.UInt32, ValueRank = ValueRanks.Scalar }; outputArguments[1] = new Argument { Name = "Revised Final State", Description = "The revised final state for the process.", DataType = DataTypeIds.UInt32, ValueRank = ValueRanks.Scalar }; start.OutputArguments.Value = inputArguments; start.OnCallMethod = OnStart; controller.AddChild(start); controller.AddReference(ReferenceTypeIds.HasNotifier, true, ObjectIds.Server); NodeStateCollection = new NodeStateCollection { controller }; }
/// <summary> /// Initializes a new instance of the <see cref="MonitoredNode2"/> class. /// </summary> /// <param name="nodeManager">The node manager.</param> /// <param name="node">The node.</param> public MonitoredNode2(CustomNodeManager2 nodeManager, NodeState node) { NodeManager = nodeManager; Node = node; }
public NodeFactory(CustomNodeManager2 customManager) { this.m_customManager = customManager; }