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 + "]";
|
}
|
}
|