コード例 #1
0
        public void TryFindChildren()
        {
            if (Root == 0)
            {
                return;
            }

            IHSApplication hs = _plugin.hs;

            DeviceClass root = (DeviceClass)hs.GetDeviceByRef(Root);

            foreach (int childRef in root.get_AssociatedDevices(hs))
            {
                DeviceClass   child   = (DeviceClass)hs.GetDeviceByRef(childRef);
                SubDeviceType subType = (SubDeviceType)int.Parse(child.get_Address(hs).Split('-')[1]);
                switch (subType)
                {
                case SubDeviceType.Brightness:
                    Brightness = childRef;
                    break;

                case SubDeviceType.Color:
                    Color = childRef;
                    break;

                case SubDeviceType.Temperature:
                    Temperature = childRef;
                    break;
                }
            }
        }
コード例 #2
0
        public string GetSubDeviceAddress(SubDeviceType type)
        {
            if (type == SubDeviceType.Root)
            {
                return(Address);
            }

            return(Address + '-' + ((int)type).ToString("D2"));
        }
コード例 #3
0
        public List <SubDeviceType> GetSubEntities()
        {
            var entities = new List <SubDeviceType>();

            using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Rs.Sql_DeviceType_Repository_GetSubEntities, null)) {
                while (rdr.Read())
                {
                    var entity = new SubDeviceType();
                    entity.Id           = SqlTypeConverter.DBNullStringHandler(rdr["Id"]);
                    entity.Name         = SqlTypeConverter.DBNullStringHandler(rdr["Name"]);
                    entity.DeviceTypeId = SqlTypeConverter.DBNullStringHandler(rdr["DeviceTypeId"]);
                    entities.Add(entity);
                }
            }
            return(entities);
        }
コード例 #4
0
        public SubDeviceType GetSubEntity(string id)
        {
            SqlParameter[] parms = { new SqlParameter("@Id", SqlDbType.VarChar, 100) };
            parms[0].Value = SqlTypeConverter.DBNullStringChecker(id);

            SubDeviceType entity = null;

            using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Rs.Sql_DeviceType_Repository_GetSubEntity, parms)) {
                if (rdr.Read())
                {
                    entity              = new SubDeviceType();
                    entity.Id           = SqlTypeConverter.DBNullStringHandler(rdr["Id"]);
                    entity.Name         = SqlTypeConverter.DBNullStringHandler(rdr["Name"]);
                    entity.DeviceTypeId = SqlTypeConverter.DBNullStringHandler(rdr["DeviceTypeId"]);
                }
            }
            return(entity);
        }