package com.dev.data;
|
|
public class ConfigData {
|
|
//¸æ¾¯±àºÅ¶ÔÓ¦¹ØÏµ
|
public static final int ALARM_TYPE_NULL = -1; //²»´¥·¢¸æ¾¯
|
public static final int ALARM_TYPE_BIG = 1; //´óÓڸ澯
|
public static final int ALARM_TYPE_BIGBIG = 2; //´óÓÚ´óÓڸ澯
|
public static final int ALARM_TYPE_SMALL = 3; //СÓڸ澯
|
public static final int ALARM_TYPE_SMALLSMALL = 4; //СÓÚСÓڸ澯
|
public static final int ALARM_TYPE_EQUAL = 5; //µÈÓڸ澯
|
public static final int ALARM_TYPE_NOTEQUAL = 6; //²»´¥·¢¸æ¾¯
|
|
|
public int dev_id; //É豸id
|
public int dev_number; //Êý¾Ý±àºÅ
|
public String dev_num; //Êý¾Ý±àºÅstr
|
public String data_value; //Êý¾ÝÃû³Æ
|
public String unit; //µ¥Î»
|
public float value_min; //×îСֵ
|
public float value_max; //×î´óÖµ
|
public float dataacc; //¾«¶È(1->ÕûÊý£»10->0.1;100->0.01)
|
public int alm_num1 = -1; //±¨¾¯1±àºÅ
|
public float alm_num1_value; //±¨¾¯1¸æ¾¯Öµ
|
public int alm_num2 = -1; //±¨¾¯2±àºÅ
|
public float alm_num2_value; //±¨¾¯2¸æ¾¯Öµ
|
public String varname; //±äÁ¿Ãû³Æ
|
public String vname = ""; //É豸±êʶ·û
|
public String macsource; //ʵʱÊý¾Ý¿âËù´¦¼ÆËã»ú
|
public String datasource; //Êý¾ÝÔ´
|
public String dataaccess; //»ñȡ;¾¶
|
public int vartype; //±äÁ¿ÀàÐÍ(1¡ª>Ä£ÄâÁ¿;2->¿ª¹ØÁ¿;3->״̬Á¿)
|
public String wanlogo; //ÒÔÌ«Íø±êʶ
|
public int frameposit; //Ö¡ÖÐλÖÃ
|
public float defalutval; //ĬÈÏÖµ
|
public String codename; //´úºÅ
|
public float value; //µ±Ç°×Ö¶ÎÖµ
|
|
public int update_code; //¸üбêʶ[0:ʵʱ¸üУ»1:°´Ðè¸üÐÂ]
|
public int update_en; //ÐèÒª¸üÐÂ[0:²»ÐèÒª¸üÐÂ;1:ÐèÒª¸üÐÂ]
|
|
//¸æ¾¯´¥·¢×Ö¶Î
|
public boolean isNewUpdate = true; //ÊÇ·ñ¸üи澯Êý¾Ý true:ÐèÒª¸üи澯¼Ç¼ false:²»ÐèÒª¸üмǼ
|
public boolean alarm_en = false; //ÊÇ·ñ´¥·¢¸æ¾¯ true:´¥·¢¸æ¾¯ false:¸æ¾¯Ïûʧ
|
public int alarm_type = 0; //¸æ¾¯ÀàÐÍ1:ÉÏÏ޸澯 2:ÏÂÏ޸澯 3:²»µÈ¸æ¾¯ 4£ºµÈÓڸ澯
|
|
|
public int getDev_number() {
|
return dev_number;
|
}
|
public String getDev_num() {
|
return dev_num;
|
}
|
public String getData_value() {
|
return data_value;
|
}
|
public String getUnit() {
|
return unit;
|
}
|
public float getValue_min() {
|
return value_min;
|
}
|
public float getValue_max() {
|
return value_max;
|
}
|
public float getDataacc() {
|
return dataacc;
|
}
|
public float getAlm_num1() {
|
return alm_num1;
|
}
|
public float getAlm_num1_value() {
|
return alm_num1_value;
|
}
|
public float getAlm_num2() {
|
return alm_num2;
|
}
|
public float getAlm_num2_value() {
|
return alm_num2_value;
|
}
|
public String getVarname() {
|
return varname;
|
}
|
public String getVname() {
|
return vname;
|
}
|
public String getMacsource() {
|
return macsource;
|
}
|
public String getDatasource() {
|
return datasource;
|
}
|
public String getDataaccess() {
|
return dataaccess;
|
}
|
public int getVartype() {
|
return vartype;
|
}
|
public String getWanlogo() {
|
return wanlogo;
|
}
|
public int getFrameposit() {
|
return frameposit;
|
}
|
public float getDefalutval() {
|
return defalutval;
|
}
|
public String getCodename() {
|
return codename;
|
}
|
public void setDev_number(int dev_number) {
|
this.dev_number = dev_number;
|
}
|
public void setDev_num(String dev_num) {
|
this.dev_num = dev_num;
|
}
|
public void setData_value(String data_value) {
|
this.data_value = data_value;
|
}
|
public void setUnit(String unit) {
|
this.unit = unit;
|
}
|
public void setValue_min(float value_min) {
|
this.value_min = value_min;
|
}
|
public void setValue_max(float value_max) {
|
this.value_max = value_max;
|
}
|
public void setDataacc(float dataacc) {
|
this.dataacc = dataacc;
|
}
|
public void setAlm_num1(int alm_num1) {
|
this.alm_num1 = alm_num1;
|
}
|
public void setAlm_num1_value(float alm_num1_value) {
|
this.alm_num1_value = alm_num1_value;
|
}
|
public void setAlm_num2(int alm_num2) {
|
this.alm_num2 = alm_num2;
|
}
|
public void setAlm_num2_value(float alm_num2_value) {
|
this.alm_num2_value = alm_num2_value;
|
}
|
public void setVarname(String varname) {
|
this.varname = varname;
|
}
|
public void setVname(String vname) {
|
this.vname = vname;
|
}
|
public void setMacsource(String macsource) {
|
this.macsource = macsource;
|
}
|
public void setDatasource(String datasource) {
|
this.datasource = datasource;
|
}
|
public void setDataaccess(String dataaccess) {
|
this.dataaccess = dataaccess;
|
}
|
public void setVartype(int vartype) {
|
this.vartype = vartype;
|
}
|
public void setWanlogo(String wanlogo) {
|
this.wanlogo = wanlogo;
|
}
|
public void setFrameposit(int frameposit) {
|
this.frameposit = frameposit;
|
}
|
public void setDefalutval(float defalutval) {
|
this.defalutval = defalutval;
|
}
|
public void setCodename(String codename) {
|
this.codename = codename;
|
}
|
public float getValue() {
|
return value;
|
}
|
|
/**
|
* »ñÈ¡µ±Ç°×Ö¶ÎÊýÖµ,²¢ÖØÖõ±Ç°¸üÐÂÖµ
|
* @return
|
*/
|
public float getDataValue() {
|
this.isNewUpdate = false;
|
return this.value;
|
}
|
|
//¼ì²âµ±Ç°ÊýÖµ
|
public void setValue(float value) {
|
if(dataacc >1) {
|
//¼ÆËãʵ¼ÊÊýÖµ
|
this.value = (float)value/dataacc;
|
} else {
|
this.value = value;
|
}
|
checkAlarm(); //УÑ鏿¾¯Öµ
|
}
|
|
/**
|
* ¼ì²éµ±Ç°Êý¾Ý¸æ¾¯
|
*/
|
public void checkAlarm() {
|
boolean lastalarm_en = this.alarm_en;
|
//¼ì²â¸æ¾¯±àºÅ2
|
switch(this.alm_num2) {
|
case ALARM_TYPE_NULL:{
|
}break;
|
case ALARM_TYPE_BIG:
|
case ALARM_TYPE_BIGBIG:{
|
//´óÓڸ澯
|
if(this.value > this.alm_num2_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_BIG;
|
}
|
}break;
|
case ALARM_TYPE_SMALL:
|
case ALARM_TYPE_SMALLSMALL:{
|
//СÓڸ澯
|
if(this.value < this.alm_num2_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_SMALL;
|
}
|
}break;
|
case ALARM_TYPE_EQUAL:{
|
//µÈÓڸ澯
|
if(this.value == this.alm_num2_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_EQUAL;
|
}
|
}break;
|
case ALARM_TYPE_NOTEQUAL:{
|
//²»µÈÓڸ澯
|
if(this.value != this.alm_num2_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_NOTEQUAL;
|
}
|
}break;
|
}
|
if(!this.alarm_en) {
|
//¼ì²â¸æ¾¯±àºÅ1
|
switch(this.alm_num1) {
|
case ALARM_TYPE_NULL:{
|
}break;
|
case ALARM_TYPE_BIG:
|
case ALARM_TYPE_BIGBIG:{
|
//´óÓڸ澯
|
if(this.value > this.alm_num1_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_BIG;
|
}
|
}break;
|
case ALARM_TYPE_SMALL:
|
case ALARM_TYPE_SMALLSMALL:{
|
//СÓڸ澯
|
if(this.value < this.alm_num1_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_SMALL;
|
}
|
}break;
|
case ALARM_TYPE_EQUAL:{
|
//µÈÓڸ澯
|
if(this.value == this.alm_num1_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_EQUAL;
|
}
|
}break;
|
case ALARM_TYPE_NOTEQUAL:{
|
//²»µÈÓڸ澯
|
if(this.value != this.alm_num1_value) {
|
this.alarm_en = true;
|
this.alarm_type = ALARM_TYPE_NOTEQUAL;
|
}
|
}break;
|
}
|
}
|
if(lastalarm_en != this.alarm_en) {
|
isNewUpdate = true;
|
}
|
}
|
|
//ÅжÏÊÇ·ñÐèÒª¸üÐÂ״̬
|
public boolean checkCanUpdate(ConfigData cfg,int update_en) {
|
if(cfg.update_code == 0 || (cfg.update_code ==1 && update_en == 1)) {
|
cfg.update_en = 1;
|
return true;
|
}
|
return false;
|
}
|
|
@Override
|
public String toString() {
|
return "ConfigData [dev_id="+dev_id+",dev_number=" + dev_number + ", dev_num=" + dev_num + ", data_value=" + data_value
|
+ ", unit=" + unit + ", value_min=" + value_min + ", value_max=" + value_max + ", dataacc=" + dataacc
|
+ ", alm_num1=" + alm_num1 + ", alm_num1_value=" + alm_num1_value + ", alm_num2=" + alm_num2
|
+ ", alm_num2_value=" + alm_num2_value + ", varname=" + varname + ", vname=" + vname + ", macsource="
|
+ macsource + ", datasource=" + datasource + ", dataaccess=" + dataaccess + ", vartype=" + vartype
|
+ ", wanlogo=" + wanlogo + ", frameposit=" + frameposit + ", defalutval=" + defalutval + ", codename="
|
+ codename + "]";
|
}
|
|
|
public static void main(String[] args) {
|
|
}
|
}
|