Esempio n. 1
0
        /// <summary>
        /// update device info
        /// </summary>
        /// <param name="force">COMMENT</param>
        public void update_info(bool force = true, bool reset_err = false)
        {
            // Store current setting and temporary set to true if 'force'
            bool fu = this.FullUpdate;

            FullUpdate = force;

            Name = deviceHS.get_Name(_hs_full_update);
            // Set device Type to "Virtual", only if it's not set yet and only for my plugin
            CheckType(deflt: "Virtual");

            // Don't get them here unnecessary, only when needed in vspsList()
            // Here just reset them - to force update when needed
            //_StateDevice = null;
            //triggerGroups = null;

            // restore prvious setting
            FullUpdate = fu;

            if (reset_err)
            {
                Attention = null; // Remove "Attention"
                Error     = "";   // Reset Error
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 2. Helper for above GetDevices - selects devices filtered by Location and/or Location2
        /// </summary>
        /// <param name="Location"></param>
        /// <param name="Location2"></param>
        /// <param name="devices">Full DeviceDictHS, can be "null", then will retrieve inside</param>
        /// <param name="min_vspsCount">Filter devices if their vspsCount exceeds this number</param>
        /// <param name="exclude">List<dev_ids> to exclude</param>
        /// <returns>List of pairs (Name=name, Value=deviceID) for dropbox</returns>
        public static MyPairList GetDevices(string Location,
                                            string Location2,
                                            DeviceDictHS devices = null,
                                            int min_vspsCount    = 0,
                                            DeviceIdList exclude = null)
        {
            IHSApplication _hs = null;

            //IHSApplication _hs = Hs;

            if (devices == null)
            {
                devices = Devices();
            }

            if (exclude == null)
            {
                exclude = new DeviceIdList();
            }

            MyPairList items = new MyPairList();

            foreach (int deviceId in devices.Keys)
            {
                if (exclude.Contains(deviceId))
                {
                    continue;
                }

                HSDevice device   = devices[deviceId];
                string   name     = device.get_Name(_hs);
                string   dev_loc  = device.get_Location(_hs);
                string   dev_loc2 = device.get_Location2(_hs);
                // Select devices matching Loc/Loc2, or if Loc/Loc2 not specified
                if ((String.IsNullOrEmpty(Location) || Location == dev_loc) &&
                    (String.IsNullOrEmpty(Location2) || Location2 == dev_loc2)
                    )
                {
                    // If Loc/Loc2 not specified - prepend them to device name
                    if (String.IsNullOrEmpty(Location))
                    {
                        name = "[" + dev_loc + "] " + name;
                    }
                    if (String.IsNullOrEmpty(Location2))
                    {
                        name = "[" + dev_loc2 + "] " + name;
                    }

                    int num_vsps = 0;
                    if (min_vspsCount > 0)
                    {
                        VSVGPairs.VSPair[] vsps = Hs.DeviceVSP_GetAllStatus(deviceId);
                        num_vsps = vsps.Length;
                    }

                    if (num_vsps >= min_vspsCount)
                    {
                        items.Add(new MyPair(name, deviceId));
                    }
                }
            }
            return(items);
        }