package com.dev.fbs9009;
|
|
import java.nio.ByteBuffer;
|
|
import com.base.ComBase;
|
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;
|
|
/**
|
* »ã¼¯Æ÷²ÎÊý
|
* @author LiJun
|
*
|
*/
|
public class ConcentratorParam {
|
|
public static final int BYTE_LEN = 17;
|
|
private int op_cmd;
|
|
private int addr; //»ã¼¯Æ÷µØÖ·£¨£©
|
private int firthMonCount; //µÚһ·µ¥Ìå¸öÊý
|
private int secondMonCount; //µÚ¶þ·µ¥Ìå¸öÊý
|
private int thirdMonCount; //µÚÈý·µ¥Ìå¸öÊý
|
private int fourthMonCount; //µÚËÄ·µ¥Ìå¸öÊý
|
private int fifthMonCount; //µÚÎå·µ¥Ìå¸öÊý
|
|
private int currRange; //µçÁ÷ǯÁ¿³Ì
|
private double floatCurrLimit; //¸¡³äµçÁ÷ÃÅÏÞ(0.1)
|
private double rippleCurrLimit; //ÎÆ²¨µçÁ÷·§Öµ(0.01)
|
private int autoTestCycle; //×Ô¶¯²âÊÔÖÜÆÚ(Сʱ)
|
private int resTestType; //ÄÚ×è²âÊÔ·½·¨(0-·Åµç 1-¼²¨·¨ 2×Ô¶¯)
|
private int dischargeType; //·Åµçģʽ(0-µ¥½Ú·Åµç 1-¹ã²¥·Åµç)
|
private int battCapStd; //±ê³ÆÈÝÁ¿(0-9999)
|
|
private int backup1; //±¸ÓÃ
|
private int backup2; //±¸ÓÃ
|
private int backup3; //±¸ÓÃ
|
private int backup4; //±¸ÓÃ
|
|
public BaseData baseData = new BaseData();
|
|
public boolean setConcenParam(ByteBuffer bf) {
|
ByteBuffer tmpbuf = bf;
|
tmpbuf.position(0);
|
if(!this.baseData.putByteBuffer(bf)){
|
return false;
|
}
|
this.addr = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.firthMonCount = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.secondMonCount = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.thirdMonCount = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.fourthMonCount = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.fifthMonCount = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.currRange = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.floatCurrLimit = ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
this.rippleCurrLimit = ComBase.changeShortToDouble(tmpbuf.getShort())/100;
|
this.autoTestCycle = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.resTestType = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.dischargeType = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.battCapStd = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup1 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup2 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup3 = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.backup4 = ComBase.changeShortToInt(tmpbuf.getShort());
|
return true;
|
}
|
|
public void putByteBuffer(ByteBuffer bytebuffer) {
|
bytebuffer.putShort(ComBase.changeIntToShort(this.addr));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.firthMonCount));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.secondMonCount));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.thirdMonCount));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.fourthMonCount));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.fifthMonCount));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.currRange));
|
bytebuffer.putShort(ComBase.changeDoubleToShort(this.floatCurrLimit*10));
|
bytebuffer.putShort(ComBase.changeDoubleToShort(this.rippleCurrLimit*100));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.autoTestCycle));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.resTestType));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.dischargeType));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.battCapStd));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.backup1));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.backup2));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.backup3));
|
bytebuffer.putShort(ComBase.changeIntToShort(this.backup4));
|
|
}
|
|
public int getAddr() {
|
return addr;
|
}
|
public int getFirthMonCount() {
|
return firthMonCount;
|
}
|
public int getSecondMonCount() {
|
return secondMonCount;
|
}
|
public int getThirdMonCount() {
|
return thirdMonCount;
|
}
|
public int getFourthMonCount() {
|
return fourthMonCount;
|
}
|
public int getFifthMonCount() {
|
return fifthMonCount;
|
}
|
public int getCurrRange() {
|
return currRange;
|
}
|
public double getFloatCurrLimit() {
|
return floatCurrLimit;
|
}
|
public double getRippleCurrLimit() {
|
return rippleCurrLimit;
|
}
|
public int getAutoTestCycle() {
|
return autoTestCycle;
|
}
|
public int getResTestType() {
|
return resTestType;
|
}
|
public int getDischargeType() {
|
return dischargeType;
|
}
|
public int getBattCapStd() {
|
return battCapStd;
|
}
|
public int getBackup1() {
|
return backup1;
|
}
|
public int getBackup2() {
|
return backup2;
|
}
|
public int getBackup3() {
|
return backup3;
|
}
|
public int getBackup4() {
|
return backup4;
|
}
|
public void setAddr(int addr) {
|
this.addr = addr;
|
}
|
public void setFirthMonCount(int firthMonCount) {
|
this.firthMonCount = firthMonCount;
|
}
|
public void setSecondMonCount(int secondMonCount) {
|
this.secondMonCount = secondMonCount;
|
}
|
public void setThirdMonCount(int thirdMonCount) {
|
this.thirdMonCount = thirdMonCount;
|
}
|
public void setFourthMonCount(int fourthMonCount) {
|
this.fourthMonCount = fourthMonCount;
|
}
|
public void setFifthMonCount(int fifthMonCount) {
|
this.fifthMonCount = fifthMonCount;
|
}
|
public void setCurrRange(int currRange) {
|
this.currRange = currRange;
|
}
|
public void setFloatCurrLimit(double floatCurrLimit) {
|
this.floatCurrLimit = floatCurrLimit;
|
}
|
public void setRippleCurrLimit(double rippleCurrLimit) {
|
this.rippleCurrLimit = rippleCurrLimit;
|
}
|
public void setAutoTestCycle(int autoTestCycle) {
|
this.autoTestCycle = autoTestCycle;
|
}
|
public void setResTestType(int resTestType) {
|
this.resTestType = resTestType;
|
}
|
public void setDischargeType(int dischargeType) {
|
this.dischargeType = dischargeType;
|
}
|
public void setBattCapStd(int battCapStd) {
|
this.battCapStd = battCapStd;
|
}
|
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 int getOp_cmd() {
|
return op_cmd;
|
}
|
public void setOp_cmd(int op_cmd) {
|
this.op_cmd = op_cmd;
|
}
|
|
public BatchRead<Integer> createConcenParamBatchRead(MyModbusMaster master) {
|
int offset = MyModBusCom.LD_BATT_COLLECTIO_PARAM_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)); //±¸ÓÃ
|
return batch;
|
}
|
|
public boolean putConcenParamBatchResult(BatchResults<Integer> res) {
|
if(null != res) {
|
int index = 0;
|
this.addr = res.getIntValue(index++);
|
this.firthMonCount = res.getIntValue(index++);
|
this.secondMonCount = res.getIntValue(index++);
|
this.thirdMonCount = res.getIntValue(index++);
|
this.fourthMonCount = res.getIntValue(index++);
|
this.fifthMonCount = res.getIntValue(index++);
|
this.currRange = res.getIntValue(index++);
|
this.floatCurrLimit = (double)res.getIntValue(index++)/10;
|
this.rippleCurrLimit = (double)res.getIntValue(index++)/100;
|
this.autoTestCycle = res.getIntValue(index++);
|
this.resTestType = res.getIntValue(index++);
|
this.dischargeType = res.getIntValue(index++);
|
this.battCapStd = res.getIntValue(index++);
|
this.backup1 = res.getIntValue(index++);
|
this.backup2 = res.getIntValue(index++);
|
this.backup3 = res.getIntValue(index++);
|
this.backup4 = res.getIntValue(index++);
|
return true;
|
}
|
return false;
|
}
|
|
|
public boolean setUpConcenParam(MyModbusMaster master) {
|
int offset = MyModBusCom.LD_BATT_COLLECTIO_PARAM_ADDR;
|
int index = offset;
|
|
boolean flag = MyModbusUtils.writeHoldingRegister(index++, this.addr, DataType.TWO_BYTE_INT_UNSIGNED, master); //²âÊÔÆðʼµç³ØÐòºÅ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.firthMonCount, DataType.TWO_BYTE_INT_UNSIGNED, master); //±ê³ÆÈÝÁ¿
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.secondMonCount, DataType.TWO_BYTE_INT_UNSIGNED, master); //·ÅµçµçÁ÷
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.thirdMonCount, DataType.TWO_BYTE_INT_UNSIGNED, master); //µ¥ÌåÏÂÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.fourthMonCount, DataType.TWO_BYTE_INT_UNSIGNED, master); //³äµçµçÁ÷
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.fifthMonCount, DataType.TWO_BYTE_INT_UNSIGNED, master); //µ¥ÌåÉÏÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.currRange, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÔÚÏßµçѹ·§Öµ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.floatCurrLimit*10, DataType.TWO_BYTE_INT_UNSIGNED, master); //³äµçµçÁ÷ÏÂÏÞ·§Öµ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.rippleCurrLimit*100, DataType.TWO_BYTE_INT_UNSIGNED, master); //³äµçÈÝÁ¿ÏÂÏÞÂÊ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.autoTestCycle, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÔÚÏßµçѹ»Ö¸´·§Öµ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.resTestType, DataType.TWO_BYTE_INT_UNSIGNED, master); //Ä£¿éµØÖ·
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.dischargeType, DataType.TWO_BYTE_INT_UNSIGNED, master); //¾ùºâ¹¦ÄÜÆôÍ£
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.battCapStd, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÈÝÁ¿ÏÂÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.backup1, DataType.TWO_BYTE_INT_UNSIGNED, master); //Êý¾ÝÀ´Ô´
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.backup2, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÄÚ×è²âÊÔϵÊý
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.backup3, DataType.TWO_BYTE_INT_UNSIGNED, master); //ζÈÉÏÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.backup4*10, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÄÚ×èÉÏÏÞ
|
|
return flag;
|
}
|
}
|