//TODO: Change the registration of laser scanners
        void World_ComponentRemoving(object sender, ComponentRemovingEventArgs args)
        {
            ILaserScanner found = null;

            foreach (ILaserScanner laser_scanner in laser_scanners)
            {
                if (laser_scanner.Component.Equals(args.Component))
                {
                    // found
                    found = laser_scanner;
                }
            }
            if (found != null)
            {
                ms.AppendMessage("Removing LaserScanner from RobotController!", MessageLevel.Warning);
                found.OnHumanDetected -= OutputOnHumanDetected;
                laser_scanners.Remove(found);
                ms.AppendMessage("LaserScanners: " + laser_scanners.Count(), MessageLevel.Warning);
            }
        }
示例#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);
        }