wxr
2021-03-15 6e580804d74d7a6fb118b6ba381e88aa81f267c7
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
using System;
using System.Collections.Generic;
 
namespace HDL_ON.Entity
{
    public class FloorHeating
    {
        /// <summary>
        /// 获取温度单位bus标识
        /// </summary>
        /// <param name="function"></param>
        /// <returns></returns>
        public int GetTempUintIndex(Function function)
        {
            var tt = function.GetAttrState(FunctionAttributeKey.TempType);
            if (tt == "°F")
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
        /// <summary>
        /// 根据bus标识设置温度单位
        /// </summary>
        /// <param name="function"></param>
        /// <returns></returns>
        public void SetTempUint(Function function, int index)
        {
            if (index == 0)
            {
                function.SetAttrState(FunctionAttributeKey.TempType, "°C");
            }
            else
            {
                function.SetAttrState(FunctionAttributeKey.TempType, "°F");
            }
        }
 
        /// <summary>
        /// 获取bus协议工作模式index
        /// 0:地热模式;1:地冷模式;
        /// 2:地热功率模式;3:地冷功率模式;
        /// </summary>
        public int GetWorkModeIndex(Function function)
        {
            var attr = function.GetAttrState(FunctionAttributeKey.WorkMode);
            if (attr == "cool")
                return 1;
            return 0;
        }
 
        /// <summary>
        /// 设置bus协议工作模式index
        /// 0:地热模式;1:地冷模式;
        /// 2:地热功率模式;3:地冷功率模式;
        /// </summary>
        public void SetWorkModeIndex(Function function, int index)
        {
            if (index == 1)
                function.SetAttrState(FunctionAttributeKey.WorkMode, "cool");
            else
                function.SetAttrState(FunctionAttributeKey.WorkMode, "heat");
        }
 
        /// <summary>
        /// 获取温度模式字符
        /// </summary>
        public string GetTempUnitString(Function function)
        {
            var tt = function.GetAttrState(FunctionAttributeKey.TempType);
            if (tt == "0")
            {
                return "°C";
            }
            else
            {
                return tt;
            }
        }
 
     
 
        /// <summary>
        /// 获取bus协议模式索引
        /// </summary>
        public byte GetModeIndex(Function function)
        {
            byte index = 0;
            var mode = function.GetAttrState(FunctionAttributeKey.Mode);
            switch (mode)
            {
                case "day":
                    index = 2;
                    break;
                case "night":
                    index = 3;
                    break;
                case "away":
                    index = 4;
                    break;
                case "normal":
                    index = 1;
                    break;
                case "timer":
                    index = 5;
                    break;
                default:
                    index = 0;
                    break;
            }
            return index;
        }
        /// <summary>
        /// 设置bus协议模式索引
        /// </summary>
        public void SetModeIndex(int value, Function function)
        {
            string mode = "timer";
            switch (value)
            {
                case 5:
                    mode = "timer";
                    break;
                case 1:
                    mode = "normal";
                    break;
                case 2:
                    mode = "day";
                    break;
                case 3:
                    mode = "night";
                    break;
                case 4:
                    mode = "away";
                    break;
                default:
                    mode = "cool";
                    break;
            }
            function.SetAttrState(FunctionAttributeKey.Mode, mode);
        }
 
        /// <summary>
        /// 时间标记
        /// 0:白天;1:夜晚
        /// </summary>
        public byte timeFlag = 0;
 
        /// <summary>
        /// 获取模式的icon路径
        /// </summary>
        public string GetModeImage(Function function)
        {
            var imagePath = "FunctionIcon/AC/HeatingIcon.png";
            var key = function.GetAttrState(FunctionAttributeKey.Mode);
            switch (key)
            {
                case "day":
                    imagePath = "FunctionIcon/AC/HeatingIcon.png";
                    break;
                case "night":
                    imagePath = "FunctionIcon/FloorHeating/NightIcon.png";
                    break;
                case "away":
                    imagePath = "FunctionIcon/FloorHeating/AwayIcon.png";
                    break;
                case "timer":
                    imagePath = "FunctionIcon/AC/AutoIcon.png";
                    break;
                case "normal":
                    imagePath = "FunctionIcon/FloorHeating/OrdinaryIcon.png";
                    break;
                default:
                    imagePath = "FunctionIcon/AC/HeatingIcon.png";
                    break;
            }
            return imagePath;
        }
    }
}