示例#1
0
        ///<summary>
        ///List of all devices in HomeSeer. Used to enable Linq queries on devices.
        ///</summary>
        ///<returns>Generic.List() of all devices</returns>
        ///<remarks>By Moskus</remarks>
        public static DeviceDictHS Devices()
        {
            DeviceDictHS ret = new DeviceDictHS();

            Scheduler.Classes.clsDeviceEnumeration deviceEnumeration = (clsDeviceEnumeration)Hs.GetDeviceEnumerator();
            while (!deviceEnumeration.Finished)
            {
                HSDevice device = deviceEnumeration.GetNext();
                ret[device.get_Ref(null)] = device;
            }
            return(ret);
        }
示例#2
0
        static internal List <DeviceDataPoint> Get_Device_List(List <DeviceDataPoint> deviceList)
        {
            // Gets relevant devices from HomeSeer
            DeviceClass dv = new DeviceClass();

            try
            {
                Scheduler.Classes.clsDeviceEnumeration EN = default(Scheduler.Classes.clsDeviceEnumeration);
                EN = (Scheduler.Classes.clsDeviceEnumeration)Util.hs.GetDeviceEnumerator();
                if (EN == null)
                {
                    throw new Exception(IFACE_NAME + " failed to get a device enumerator from HomeSeer.");
                }
                int dvRef;

                do
                {
                    dv = EN.GetNext();
                    if (dv == null)
                    {
                        continue;
                    }
                    if (dv.get_Interface(null) != IFACE_NAME)
                    {
                        continue;
                    }
                    dvRef = dv.get_Ref(null);

                    var ddp = new DeviceDataPoint(dvRef, dv);
                    deviceList.Add(ddp);
                } while (!(EN.Finished));
            }
            catch (Exception ex)
            {
                Log("Exception in Get_Device_List: " + ex.Message, LogType.LOG_TYPE_ERROR);
            }

            return(deviceList);
        }