JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
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
184
185
186
187
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shared.SimpleControl.Phone;
 
namespace Shared
{
    /// <summary>
    /// 地热模块
    /// </summary>
[System.Serializable]
    public class FoolHeat:Common
    {
        public FoolHeat ()
        {
            this.Type = DeviceType.FoolHeat;;
            DeviceTextID = 104; //SimpleControl.R.MyInternationalizationString.FoolHeat;
        }
 
        /// <summary>
        /// 工作模式
        /// 0制热,1制冷,2,3
        /// </summary>
        public byte WorkingMode = 0;
 
 
        /// <summary>
        /// 温度模式
        /// 1 = Normal, 2 = Day , 3 = Night, 4 = Away, 5 = Timer
        /// </summary>
        public byte TemperatureType;
        /// <summary>
        /// 正常模式工作温度
        /// </summary>
        public byte NormalTemperature;
        /// <summary>
        /// 白天模式工作温度
        /// </summary>
        public byte DayTemperature;
        /// <summary>
        /// 晚上模式工作温度
        /// </summary>
        public byte NightTemperature;
        /// <summary>
        /// 离开模式工作温度
        /// </summary>
        public byte AwayTemperature;
 
        /// <summary>
        /// 时间模式工作标记
        /// 0 = Day, 1 = Night
        /// </summary>
        public byte Timer;//
 
        /// <summary>
        /// 开关状态
        /// </summary>
        public byte Status;
        /// <summary>
        /// 阀的开关状态(0--关   1--开)
        /// </summary>
        public byte PWDStatus;
        public byte PWDValue;//0-100
 
        /// <summary>
        /// 清洗标记
        /// </summary>
        public byte WateringFlag;
 
        /// <summary>
        /// 清洗时间
        /// </summary>
        public byte WateringTime;
 
        /// <summary>
        /// 工作温度
        /// </summary>
        public byte WorkingTemperature =5;
        /// <summary>
        /// The PIDS peed.
        /// </summary>
        public byte PIDSpeed;
        /// <summary>
        /// 室内温度
        /// </summary>
        public byte IndoorTemperature;
        /// <summary>
        /// 地板温度
        /// </summary>
        public byte FloorTemperature;
 
        public byte[] FH_Bytes;
 
        public FoolHeat Serverx_FH_CMD (CommandType commandType, byte[] updataBytes = null)
        {
            if (updataBytes != null)
                FH_Bytes = updataBytes;
            if (commandType == CommandType.Read) {
                FH_Bytes = Control.ControlBytesSendHasReturn (Command.ReadFoolHeat, SubnetID, DeviceID, new byte [] { LoopID });
                return this;
            }
            if (FH_Bytes == null)
                return this;
            if (commandType == CommandType.Switch || commandType == CommandType.WorkMode) {
                FH_Bytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, SubnetID, DeviceID, new byte [] { LoopID, (byte)(Status + WorkingMode * 16), FH_Bytes [2], FH_Bytes [3], FH_Bytes [4], FH_Bytes [5], FH_Bytes [6], FH_Bytes [7], 0, 0 });
                return this;
            } else if (commandType == CommandType.Temperatrue) {
                switch (TemperatureType) {
                case 1://普通
                    FH_Bytes [4] = this.WorkingTemperature;
                    break;
                case 2://白天
                    FH_Bytes [5] = this.WorkingTemperature;
                    break;
                case 3://夜晚
                    FH_Bytes [6] = this.WorkingTemperature;
                    break;
                case 4://离开
                    FH_Bytes [7] = this.WorkingTemperature;
                    break;
                case 5://时间模式
                    if (FH_Bytes [8] == 1)//时间模式的时间段标志 (0:白天,1:夜晚) (1byte)     //20110112加时间段标志
                        FH_Bytes [4] = this.WorkingTemperature;
                    else
                        FH_Bytes [5] = this.WorkingTemperature;
                    break;
                }
                FH_Bytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, SubnetID, DeviceID, new byte [] { LoopID, FH_Bytes [1], FH_Bytes [2], FH_Bytes [3], FH_Bytes [4], FH_Bytes [5], FH_Bytes [6], FH_Bytes [7], 0, 0 });
                return this;
            } else if (commandType == CommandType.TemperatrueMode) {
                FH_Bytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, SubnetID, DeviceID, new byte [] { LoopID, FH_Bytes [1], FH_Bytes [2], TemperatureType, FH_Bytes [4], FH_Bytes [5], FH_Bytes [6], FH_Bytes [7], 0, 0 });
                return this;
            } 
 
            this.WorkingMode = FH_Bytes [1] > 10 ? (byte)1 : (byte)0;
            this.Status = (byte)(FH_Bytes [1] % 2);
            this.TemperatureType = FH_Bytes [3];
            switch (FH_Bytes [3]) {
            case 1://普通
                this.WorkingTemperature = FH_Bytes [4];
                break;
            case 2://白天
                this.WorkingTemperature = FH_Bytes [5];
                break;
            case 3://夜晚
                this.WorkingTemperature = FH_Bytes [6];
                break;
            case 4://离开
                this.WorkingTemperature = FH_Bytes [7];
                break;
            case 5://时间模式
                if (FH_Bytes [8] == 1)//时间模式的时间段标志 (0:白天,1:夜晚) (1byte)     //20110112加时间段标志
                    this.WorkingTemperature = FH_Bytes [5];
                else
                    this.WorkingTemperature = FH_Bytes [6];
                break;
            }
            this.IndoorTemperature = FH_Bytes [9] > 128 ? (byte)(0 - (FH_Bytes [9] - 128)) : FH_Bytes [9];
            this.PWDStatus = FH_Bytes [10];
            this.PWDValue = FH_Bytes [11];
            this.WateringFlag = FH_Bytes [12];
            this.WateringTime = FH_Bytes [13];
            if (updataBytes != null && commandType == CommandType.Null) {
                if (Application.IsPad) {
                    //SimpleControl.Pad.UserFHPage.UpdateStatus (this);
                } else {
                    UserDeviceToFH.UpdateStatus (this);
                    UserFHPage.UpdateStatus (this, updataBytes[0]);
                    UserRoom.UpdataDeviceStatus (this);
                }
            }
            IO.FileUtils.SaveEquipmentMessage (this, this.LoopID.ToString ());
            return this;
        }
 
        public enum CommandType
        {
            Read = 0,
            Switch = 1,
            Temperatrue =3,
            TemperatrueMode = 7,
            WorkMode = 9,
            Null = 999,
        }
    }
}