package com.dev.fbs9009;
|
|
import java.nio.ByteBuffer;
|
|
import com.base.Com;
|
import com.base.ComBase;
|
import com.dev.fbs9009.LD_batt_states.LD_batt_state;
|
import com.dev.modbus4j.MyModbusMaster;
|
import com.dev.modbus4j.MyModbusUtils;
|
import com.serotonin.modbus4j.BatchRead;
|
import com.serotonin.modbus4j.BatchResults;
|
import com.serotonin.modbus4j.code.DataType;
|
|
public class ConcentratorState {
|
public static final int BYTE_LEN = 20; //¼Ä´æÆ÷¸öÊý
|
|
private double systemVersion; //ϵͳ°æ±¾(01)
|
private int systemState; //ϵͳ״̬(0-³£¹æÄ£Ê½ 1-ÄÚ×èģʽ 2-±àַģʽ)
|
private double groupVol; //×é¶Ëµçѹ(0.1)
|
private double groupCurr; //×é¶ËµçÁ÷(0.1)
|
private int battState; //µç³Ø×´Ì¬(0-¸¡³ä 1-·Åµç 2-³äµç)
|
private int currDirection; //µçÁ÷·½Ïò(0-³äµç 1-·Åµç)
|
private double rippleCurrAvg; //ÎÆ²¨µçÁ÷¾ùÖµ(0.01)
|
private double rippleCurrTop; //ÎÆ²¨µçÁ÷·åÖµ(0.01)
|
|
private int backup1;
|
private int backup2;
|
private int backup3;
|
private int backup4;
|
private int backup5;
|
private int backup6;
|
|
private int resTestCount; //ÄÚ×è²âÊÔ´ÎÊý
|
private int resTestMethod; //ÄÚ×è²âÊÔ·½·¨(0-dµ¥½Ú·Åµç·¨ 1-¹ã²¥·Åµç·¨ 2-¼²¨·¨)
|
|
private int backup7;
|
private int backup8;
|
private int backup9;
|
private int backup10;
|
|
public BaseData baseData = new BaseData();
|
|
|
public boolean setConcenState(ByteBuffer bf) {
|
ByteBuffer tmpbuf = bf;
|
tmpbuf.position(0);
|
if(!this.baseData.putByteBuffer(bf)){
|
return false;
|
}
|
this.systemVersion = ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
this.systemState = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.groupVol = ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
this.groupCurr = ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
this.battState = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.currDirection = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.rippleCurrAvg = ComBase.changeShortToDouble(tmpbuf.getShort())/100;
|
this.rippleCurrTop = ComBase.changeShortToDouble(tmpbuf.getShort())/100;
|
this.backup1 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup2 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup3 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup4 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup5 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup6 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.resTestCount = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.resTestMethod = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup7 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup8 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup9 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup10 = ComBase.changeShortToInt(tmpbuf.getShort());
|
//this.groupCurr = 15+Math.random();
|
//this.battState = 2;
|
|
return true;
|
}
|
|
public double getSystemVersion() {
|
return systemVersion;
|
}
|
public int getSystemState() {
|
return systemState;
|
}
|
public double getGroupVol() {
|
return groupVol;
|
}
|
public double getGroupCurr() {
|
return groupCurr;
|
}
|
public int getBattState() {
|
return battState;
|
}
|
public int getCurrDirection() {
|
return currDirection;
|
}
|
public double getRippleCurrAvg() {
|
return rippleCurrAvg;
|
}
|
public double getRippleCurrTop() {
|
return rippleCurrTop;
|
}
|
public int getBackup1() {
|
return backup1;
|
}
|
public int getBackup2() {
|
return backup2;
|
}
|
public int getBackup3() {
|
return backup3;
|
}
|
public int getBackup4() {
|
return backup4;
|
}
|
public int getBackup5() {
|
return backup5;
|
}
|
public int getBackup6() {
|
return backup6;
|
}
|
public int getResTestCount() {
|
return resTestCount;
|
}
|
public int getResTestMethod() {
|
return resTestMethod;
|
}
|
public int getBackup7() {
|
return backup7;
|
}
|
public int getBackup8() {
|
return backup8;
|
}
|
public int getBackup9() {
|
return backup9;
|
}
|
public int getBackup10() {
|
return backup10;
|
}
|
public void setSystemVersion(double systemVersion) {
|
this.systemVersion = systemVersion;
|
}
|
public void setSystemState(int systemState) {
|
this.systemState = systemState;
|
}
|
public void setGroupVol(double groupVol) {
|
this.groupVol = groupVol;
|
}
|
public void setGroupCurr(double groupCurr) {
|
this.groupCurr = groupCurr;
|
}
|
public void setBattState(int battState) {
|
this.battState = battState;
|
}
|
public void setCurrDirection(int currDirection) {
|
this.currDirection = currDirection;
|
}
|
public void setRippleCurrAvg(double rippleCurrAvg) {
|
this.rippleCurrAvg = rippleCurrAvg;
|
}
|
public void setRippleCurrTop(double rippleCurrTop) {
|
this.rippleCurrTop = rippleCurrTop;
|
}
|
public void setBackup1(int backup1) {
|
this.backup1 = backup1;
|
}
|
public void setBackup2(int backup2) {
|
this.backup2 = backup2;
|
}
|
public void setBackup3(int backup3) {
|
this.backup3 = backup3;
|
}
|
public void setBackup4(int backup4) {
|
this.backup4 = backup4;
|
}
|
public void setBackup5(int backup5) {
|
this.backup5 = backup5;
|
}
|
public void setBackup6(int backup6) {
|
this.backup6 = backup6;
|
}
|
public void setResTestCount(int resTestCount) {
|
this.resTestCount = resTestCount;
|
}
|
public void setResTestMethod(int resTestMethod) {
|
this.resTestMethod = resTestMethod;
|
}
|
public void setBackup7(int backup7) {
|
this.backup7 = backup7;
|
}
|
public void setBackup8(int backup8) {
|
this.backup8 = backup8;
|
}
|
public void setBackup9(int backup9) {
|
this.backup9 = backup9;
|
}
|
public void setBackup10(int backup10) {
|
this.backup10 = backup10;
|
}
|
|
public BatchRead<Integer> createConcenStateBatchRead(MyModbusMaster master) {
|
int offset = MyModBusCom.LD_BATT_COLLECTIO_DATA_ADDR;
|
int count = 0;
|
BatchRead<Integer> batch = new BatchRead<Integer>();
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //ϵͳ°æ±¾
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //ϵͳ״̬
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //×é¶Ëµçѹ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //×é¶ËµçÁ÷
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //µç³Ø×´Ì¬
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //µçÁ÷·½Ïß
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //ÎÆ²¨µçÁ÷¾ùÖµ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //ÎÆ²¨µçÁ÷·åÖµ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //ÄÚ×è²âÊÔ´ÎÊý
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //ÄÚ×è²âÊÔ·½·¨
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
batch.addLocator(count,MyModbusUtils.createBaseLocator(offset+count++,DataType.TWO_BYTE_INT_UNSIGNED, master)); //±¸ÓÃ
|
return batch;
|
}
|
|
public boolean putConcenStateBatchResult(BatchResults<Integer> res) {
|
if(null != res) {
|
int index = 0;
|
this.systemVersion = (double)res.getIntValue(index++)/10;
|
this.systemState = res.getIntValue(index++);
|
this.groupVol = (double)res.getIntValue(index++)/10;
|
this.groupCurr = (double)res.getIntValue(index++)/10;
|
this.battState = res.getIntValue(index++);
|
this.currDirection = res.getIntValue(index++);
|
this.rippleCurrAvg = (double)res.getIntValue(index++)/100;
|
this.rippleCurrTop = (double)res.getIntValue(index++)/100;
|
this.backup1 = res.getIntValue(index++);
|
this.backup2 = res.getIntValue(index++);
|
this.backup3 = res.getIntValue(index++);
|
this.backup4 = res.getIntValue(index++);
|
this.backup5 = res.getIntValue(index++);
|
this.backup6 = res.getIntValue(index++);
|
this.resTestCount = res.getIntValue(index++);
|
this.resTestMethod = res.getIntValue(index++);
|
this.backup7 = res.getIntValue(index++);
|
this.backup8 = res.getIntValue(index++);
|
this.backup9 = res.getIntValue(index++);
|
this.backup10 = res.getIntValue(index++);
|
return true;
|
}
|
return false;
|
}
|
}
|