public static IEnumerable<ModelInterfaceSample> GetUnconfigedSampleInterfaces(this AceModelRestricted model, IConfigDll hwconfig)
        {
            var unconfigured = Enumerable.Empty<ModelInterfaceSample>();
            if ((hwconfig != null) && (model != null))
            {
                hwconfig.InitializeDll();
                //ModelElement[] configuredInterfaceElements = model.GetInterfacesOfVisaType(this.VisaIntfTypeString);  // EOS: unused, removed.
                var availableInterfaces = hwconfig.GetAvailableInterfaces().Where(i => i is ModelInterfaceSample).Select(i => i as ModelInterfaceSample);
                // TCPIP only configures 1 interface by default, but this pattern supports any number
                unconfigured = (from i in availableInterfaces
                                where model.FindEquivalentElement(i) == null
                                select i);

                hwconfig.UninitializeDll();
            }
            return unconfigured;
        }
Esempio n. 2
0
        public static IEnumerable <ModelInterfaceSample> GetUnconfigedSampleInterfaces(this AceModelRestricted model, IConfigDll hwconfig)
        {
            var unconfigured = Enumerable.Empty <ModelInterfaceSample>();

            if ((hwconfig != null) && (model != null))
            {
                hwconfig.InitializeDll();
                //ModelElement[] configuredInterfaceElements = model.GetInterfacesOfVisaType(this.VisaIntfTypeString);  // EOS: unused, removed.
                var availableInterfaces = hwconfig.GetAvailableInterfaces().Where(i => i is ModelInterfaceSample).Select(i => i as ModelInterfaceSample);
                // TCPIP only configures 1 interface by default, but this pattern supports any number
                unconfigured = (from i in availableInterfaces
                                where model.FindEquivalentElement(i) == null
                                select i);

                hwconfig.UninitializeDll();
            }
            return(unconfigured);
        }
Esempio n. 3
0
        public List <ModelElement> DoDiscovery(ModelElement discoveryRoot, AceModelRestricted model)
        {
            // Discover devices on interfaces
            // If discoveryRoot is null or empty discovery devices on all interfaces associated with this agent.
            // If discoveryRoot is specified, verify the presence of the interface and discover all devices on it.
            // - The model paramenter contains elements that are currently known - treat it as read-only
            // - Add only newly discovered or deleted elements to the output list.
            // - Notes:
            //      - Only devices are discovered here. Interfaces are discovered and added to the model in AutoConfig().
            //      - Elements in the output list will later be verified using DoVerify().
            //      - If we are not confident that a discovered device is the same as one already in the model,
            //        then we should copy it to the output List so it will later be verified.

            //string doDiscoveryTitle = string.Format("DoDiscovery of {0}", (discoveryRoot != null) ? discoveryRoot.ToString() : "<null>");
            //LogUtils.LogElements(_log, this, doDiscoveryTitle, model.GetInterfaces()); // Verbose
            if (_log != null && discoveryRoot != null)
            {
                var    id  = discoveryRoot.PersistentId;
                string msg = string.Format("Begin discovery of '{0}'", id);
                _log.Message(msg, LogUtils.MethodName(this));
            }
            var list  = new List <ModelElement>();
            var intfc = discoveryRoot as ModelInterfaceSample;

            if (intfc != null)
            {
                IConfigDll hwconfig = _container.Resolve <IConfigDll>(AgentName);
                hwconfig.InitializeDll();
                var intfcCopy       = intfc.MakeCopy() as ModelInterfaceSample;
                var availableIntfcs = hwconfig.GetAvailableInterfaces()
                                      .Where(i => i is ModelInterfaceSample)
                                      .Select(i => i as ModelInterfaceSample);
                if (intfcCopy.IsInterfacePresent(availableIntfcs) ||
                    intfc.StaticallyDefined)
                {
                    list.Add(intfcCopy);
                    FindAndUpdateDevices(hwconfig, list, intfc, model);
                }
                hwconfig.UninitializeDll();
            }
            return(list);
        }