wxr
2020-09-09 c3e1b733fc45bd9f0b88bfb560cfa87a270b079b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
 
namespace HDL_ON.Entity
{
    public class Curtain : Function
    {
        /*
        窗帘属性列表:trait: [switch,percent,lock]
        属性    描述
        on_off    on/off/stop;
        percent    0-100;
        lock    boolean (Lock锁定控制)
        */
        public Curtain()
        {
        }//percent
        [Newtonsoft.Json.JsonIgnore]
        public Trait trait_percent;
        /// <summary>
        /// 开关百分比
        /// 0-100
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int percent
        {
            get
            {
                try
                {
                    if(trait_percent==null)
                    {
                        trait_percent = function.Find((obj) => obj.name == "percent");
                        if (trait_percent == null)
                        {
                            trait_percent = new Trait()
                            {
                                name = "percent",
                                value_key = new List<string> { "up", "down" },
                                max = 100,
                                min = 0,
                            };
                        }
                        trait_percent.value = trait_percent.min;
                    }
                    return Convert.ToInt32( trait_percent.value);
                }
                catch
                {
                    MainPage.Log("percent 数据获取失败.");
                    return 0;
                }
            }
            set
            {
                try
                {
                    trait_percent.value = value;
                }
                catch
                {
                    MainPage.Log("percent 数据刷新失败.");
                }
            }
        }
 
    }
}