Exemple #1
0
        /// <summary>
        /// Add signals from VC component to component OPCUA node
        /// </summary>
        private void AddSignalNodes(ComponentState uaComponentNode, VcComponent vcComponent)
        {
            foreach (ISignal vcSignal in vcComponent.GetSignals())
            {
                // Add signal node
                BaseDataVariableState uaSignalNode = CreateVariableNode(uaComponentNode.Signals, vcSignal.Name, VcSignal2OpcuaType[vcSignal.Type]);
                uaComponentNode.Signals.AddChild(uaSignalNode);

                // Store names in UaBrowseName2VcComponentName
                UaBrowseName2VcComponentName.Add(uaSignalNode.BrowseName.Name, vcComponent.component.Name);

                // Subscribe to signal triggered events
                vcSignal.SignalTrigger    += vc_SignalTriggered;
                uaSignalNode.StateChanged += ua_SignalTriggered;
            }
        }
Exemple #2
0
        private void World_ComponentRemoving(object sender, ComponentRemovingEventArgs e)
        {
            NodeId componentId = NodeId.Create(e.Component.Name, Namespaces.vc2opcua, uaServer.NamespaceUris);

            ComponentState componentNode = (ComponentState)nodeManager.FindPredefinedNode(componentId,
                                                                                          typeof(ComponentState));

            if (componentNode != null)
            {
                nodeManager.RemoveNode(nodeManager.baseFolder, componentNode, ReferenceTypeIds.Organizes);
            }

            // Remove signals from SignalComponents property
            VcComponent vcComponent = new VcComponent(e.Component);

            foreach (ISignal signal in vcComponent.GetSignals())
            {
                string nodeNameParent = String.Format("{0}-{1}", signal.Name, vcComponent.component.Name);

                UaBrowseName2VcComponentName.Remove(nodeNameParent);
            }

            _vcUtils.VcWriteWarningMsg("Component removed: " + e.Component.Name);
        }