whyclj
2019-06-24 7db82bcad74395c674a373b4d178d122eed3006b
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package com.dev.btse.data;
 
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Date;
 
import com.battmonitor.base.ComBase;
 
public class TmpSensorState {
    public static final int REG_BYTECOUNT = 16;
    
    public int sensor_dev_id;                    //É豸id
    public Date record_time;                        //¼Ç¼ʱ¼ä
    
    private float airtmp;                    //¿ÕÆøÎ¶ȣ¨0.1¡æ£©
    private float airhum;                    //¿ÕÆøÊª¶È£¨0.1%      0~100%RH£©
    private int smoke;                        //ÑÌÎí300~10000ppm
    private int water;                        //Ë®½þ   0:ÎÞË®    1:©ˮ
    private int lightintensity;                //¹âÕÕÇ¿¶È£¨0~65535Lux£©
    private int CO2concentration;            //CO2Ũ¶È(0~5000ppm)
    private int COconcentration;            //COŨ¶È(0~1000ppm)
    private int CH4concentration;            //CH4Ũ¶È(300~10000ppm)
    private float O2concentration;            //ÑõÆøº¬Á¿(0~25%)
    
    private int backup01;                    //±¸ÓÃ1
    private int backup02;                    //±¸ÓÃ2
    private int backup03;                    //±¸ÓÃ3
    private int backup04;                    //±¸ÓÃ4
    private int backup05;                    //±¸ÓÃ5
    
    private int smokeuplimit;                //ÑÌÎíÉÏÏÞ
    private int smokelowlimit;                //ÑÌÎíÏÂÏÞ
    
    private int dev_commcount;
    private int dev_errcommcount;
    
    public ByteBuffer getReadBuffer() {
        ByteBuffer tmp = ByteBuffer.allocate(2);
        tmp.order(ByteOrder.BIG_ENDIAN);
        tmp.putShort(ComBase.changeIntToShort(REG_BYTECOUNT));
        tmp.flip();
        return tmp;
    }
    
    public boolean putByteBuffer(ByteBuffer buffer) {
        boolean flag = false;
        if(buffer.limit() < REG_BYTECOUNT) {
            //System.out.println("00000");
            flag = false;
        }else {
            this.airtmp = (float)ComBase.changeShortToDouble(buffer.getShort())/10;
            this.airhum = (float)ComBase.changeShortToDouble(buffer.getShort())/10;
            this.smoke = ComBase.changeShortToInt(buffer.getShort());
            this.water = ComBase.changeShortToInt(buffer.getShort());
            this.lightintensity = ComBase.changeShortToInt(buffer.getShort());
            this.CO2concentration = ComBase.changeShortToInt(buffer.getShort());
            this.COconcentration = ComBase.changeShortToInt(buffer.getShort());
            this.CH4concentration = ComBase.changeShortToInt(buffer.getShort());
            this.O2concentration = (float)ComBase.changeShortToDouble(buffer.getShort());
            this.backup01 = ComBase.changeShortToInt(buffer.getShort());
            this.backup02 = ComBase.changeShortToInt(buffer.getShort());
            this.backup03 = ComBase.changeShortToInt(buffer.getShort());
            this.backup04 = ComBase.changeShortToInt(buffer.getShort());
            this.backup05 = ComBase.changeShortToInt(buffer.getShort());
            this.smokeuplimit = ComBase.changeShortToInt(buffer.getShort());
            this.smokelowlimit = ComBase.changeShortToInt(buffer.getShort());
            flag = true;
        }
        return flag;
    }
    
    /**
     * ¹¹ÔìÉ豸id
     * @param cmd
     */
    public void createTmpDevid(int cmd) {
        this.sensor_dev_id = 291200000 +cmd;
    }
    
    public int getSensor_dev_id() {
        return sensor_dev_id;
    }
 
    public void setSensor_dev_id(int sensor_dev_id) {
        this.sensor_dev_id = sensor_dev_id;
    }
 
    public float getAirtmp() {
        return airtmp;
    }
    public float getAirhum() {
        return airhum;
    }
    public int getSmoke() {
        return smoke;
    }
    public int getWater() {
        return water;
    }
    public int getLightintensity() {
        return lightintensity;
    }
    public int getCO2concentration() {
        return CO2concentration;
    }
    public int getCOconcentration() {
        return COconcentration;
    }
    public int getCH4concentration() {
        return CH4concentration;
    }
    public float getO2concentration() {
        return O2concentration;
    }
    public int getBackup01() {
        return backup01;
    }
    public int getBackup02() {
        return backup02;
    }
    public int getBackup03() {
        return backup03;
    }
    public int getBackup04() {
        return backup04;
    }
    public int getBackup05() {
        return backup05;
    }
    public void setAirtmp(float airtmp) {
        this.airtmp = airtmp;
    }
    public void setAirhum(float airhum) {
        this.airhum = airhum;
    }
    public void setSmoke(int smoke) {
        this.smoke = smoke;
    }
    public void setWater(int water) {
        this.water = water;
    }
    public void setLightintensity(int lightintensity) {
        this.lightintensity = lightintensity;
    }
    public void setCO2concentration(int cO2concentration) {
        CO2concentration = cO2concentration;
    }
    public void setCOconcentration(int cOconcentration) {
        COconcentration = cOconcentration;
    }
    public void setCH4concentration(int cH4concentration) {
        CH4concentration = cH4concentration;
    }
    public void setO2concentration(float o2concentration) {
        O2concentration = o2concentration;
    }
    public void setBackup01(int backup01) {
        this.backup01 = backup01;
    }
    public void setBackup02(int backup02) {
        this.backup02 = backup02;
    }
    public void setBackup03(int backup03) {
        this.backup03 = backup03;
    }
    public void setBackup04(int backup04) {
        this.backup04 = backup04;
    }
    public void setBackup05(int backup05) {
        this.backup05 = backup05;
    }
 
    public int getSmokeuplimit() {
        return smokeuplimit;
    }
 
    public int getSmokelowlimit() {
        return smokelowlimit;
    }
 
    public void setSmokeuplimit(int smokeuplimit) {
        this.smokeuplimit = smokeuplimit;
    }
 
    public void setSmokelowlimit(int smokelowlimit) {
        this.smokelowlimit = smokelowlimit;
    }
    
    public int getDev_commcount() {
        return dev_commcount;
    }
 
    public int getDev_errcommcount() {
        return dev_errcommcount;
    }
 
    public void setDev_commcount() {
        this.dev_commcount += 1;
        if(this.dev_commcount >= 90000000) {
            this.dev_commcount = 1;
        }
    }
    
    public void clearDev_commcount() {
        this.dev_commcount = 1;
    }
 
    public void setDev_errcommcount() {
        this.dev_errcommcount += 1;
        if(this.dev_errcommcount >= 90000000) {
            this.dev_errcommcount = 1;
        }
    }
    
    public void clearDev_errcommcount() {
        this.dev_errcommcount = 1;
    }
 
    public Date getRecord_time() {
        return record_time;
    }
 
    public void setRecord_time(Date record_time) {
        this.record_time = record_time;
    }
 
    @Override
    public String toString() {
        return "TmpSensorState [sensor_dev_id=" + sensor_dev_id + ", record_time=" + record_time + ", airtmp=" + airtmp
                + ", airhum=" + airhum + ", smoke=" + smoke + ", water=" + water + ", lightintensity=" + lightintensity
                + ", CO2concentration=" + CO2concentration + ", COconcentration=" + COconcentration
                + ", CH4concentration=" + CH4concentration + ", O2concentration=" + O2concentration + ", backup01="
                + backup01 + ", backup02=" + backup02 + ", backup03=" + backup03 + ", backup04=" + backup04
                + ", backup05=" + backup05 + ", smokeuplimit=" + smokeuplimit + ", smokelowlimit=" + smokelowlimit
                + ", dev_commcount=" + dev_commcount + ", dev_errcommcount=" + dev_errcommcount + "]";
    }
}