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;
|
|
public class LD_param {
|
public static int BYTE_LEN=17; //¼Ä´æÆ÷¸öÊý
|
private int cmd; //·¢ËÍÊý¾ÝµÄÃüÁî
|
private int cmd_addr; //Ä£¿éµØÖ·
|
private int cmd_addr_back; //¼Ä´æÆ÷µÄÆðʼµØÖ·
|
private int dataCount; //Êý¾ÝµÄ³¤¶È
|
|
private int op_cmd; //ÓÃÓÚÉèÖÃÉ豸µÄ¿ØÖÆÃüÁî
|
private int param_teststart_batt_num; //²âÊÔÆðʼµç³ØÐòºÅ
|
private int param_cap; //±ê³ÆÈÝÁ¿
|
private double param_discharge_curr; //·ÅµçµçÁ÷0.001
|
private double param_mon_curr_high; //µ¥ÌåÏÂÏÞ0.001
|
private double param_charge_curr; //³äµçµçÁ÷0.001
|
private double param_mon_curr_low; //µ¥ÌåÉÏÏÞ0.001
|
private double param_online_vol; //ÔÚÏßµçѹ·§Öµ0.01
|
private double param_charge_curr_low; //³äµçµçÁ÷ÏÂÏÞ·§Öµ0.001
|
private double param_charge_cap_low; //³äµçÈÝÁ¿ÏÂÏÞ·§Öµ%
|
private double param_online_vol_recover;//ÔÚÏßµçѹ»Ö¸´·§Öµ0.01
|
private int param_module_address; //Ä£¿éµØÖ·
|
|
private int param_junheng_model; //¾ùºâ¹¦ÄܵįôÓûòÕß½ûÓà 0:½ûÓà 1:ÆôÓÃ
|
private double param_cap_low; //ÈÝÁ¿ÏÂÏÞ0.1
|
private int param_datasource; //Êý¾ÝÀ´Ô´£¨0 - ±¾»ú 1-»ã¼¯Æ÷£©
|
private int param_res_args; //ÄÚ×è²âÊÔϵÊý£¨1-100£©
|
private int param_tmp_high; //ζÈÉÏÏÞ
|
private double param_res_high; //ÄÚ×èÉÏÏÞ
|
|
|
//»ñÈ¡²ÎÊýÐÅÏ¢
|
public boolean setLD_param(ByteBuffer bf){
|
boolean flag = false;
|
ByteBuffer tmpbuf = bf;
|
tmpbuf.position(0);
|
try {
|
this.cmd_addr = ComBase.changeByteToInt(tmpbuf.get());
|
this.cmd = ComBase.changeByteToInt(tmpbuf.get()); //ÃüÁîµØÖ·
|
this.cmd_addr_back = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.dataCount = ComBase.changeByteToInt(tmpbuf.get());
|
|
//System.out.println("Êý¾ÝÇø×Ö½ÚÊýµÄ³¤¶È:"+this.dataCount);
|
this.param_teststart_batt_num = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_cap = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_discharge_curr = ComBase.changeShortToInt(tmpbuf.getShort())*0.001;
|
this.param_mon_curr_low = ComBase.changeShortToInt(tmpbuf.getShort())*0.001;
|
this.param_charge_curr = ComBase.changeShortToInt(tmpbuf.getShort())*0.001;
|
this.param_mon_curr_high= ComBase.changeShortToInt(tmpbuf.getShort())*0.001;
|
this.param_online_vol = ComBase.changeShortToInt(tmpbuf.getShort())*0.01;
|
this.param_charge_curr_low = ComBase.changeShortToInt(tmpbuf.getShort())*0.001;
|
|
this.param_charge_cap_low = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_online_vol_recover = ComBase.changeShortToInt(tmpbuf.getShort())*0.01;
|
this.param_module_address = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_junheng_model = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_cap_low = (float) (ComBase.changeShortToInt(tmpbuf.getShort())*0.1);
|
this.param_datasource = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_res_args = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_tmp_high = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.param_res_high = (float)(ComBase.changeShortToInt(tmpbuf.getShort())*0.1);
|
|
//System.err.println(this.param_cap_low+"#################");
|
flag = true;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return flag;
|
}
|
|
public int getParam_teststart_batt_num() {
|
return param_teststart_batt_num;
|
}
|
|
public void setParam_teststart_batt_num(int param_teststart_batt_num) {
|
this.param_teststart_batt_num = param_teststart_batt_num;
|
}
|
|
public int getParam_cap() {
|
return param_cap;
|
}
|
|
public void setParam_cap(int param_cap) {
|
this.param_cap = param_cap;
|
}
|
|
public double getParam_discharge_curr() {
|
return param_discharge_curr;
|
}
|
|
public void setParam_discharge_curr(double param_discharge_curr) {
|
this.param_discharge_curr = param_discharge_curr;
|
}
|
|
public double getParam_mon_curr_high() {
|
return param_mon_curr_high;
|
}
|
|
public void setParam_mon_curr_high(double param_mon_curr_high) {
|
this.param_mon_curr_high = param_mon_curr_high;
|
}
|
|
public double getParam_charge_curr() {
|
return param_charge_curr;
|
}
|
|
public void setParam_charge_curr(double param_charge_curr) {
|
this.param_charge_curr = param_charge_curr;
|
}
|
|
public double getParam_mon_curr_low() {
|
return param_mon_curr_low;
|
}
|
|
public void setParam_mon_curr_low(double param_mon_curr_low) {
|
this.param_mon_curr_low = param_mon_curr_low;
|
}
|
|
public double getParam_online_vol() {
|
return param_online_vol;
|
}
|
|
public void setParam_online_vol(double param_online_vol) {
|
this.param_online_vol = param_online_vol;
|
}
|
|
|
public double getParam_cap_low() {
|
return param_cap_low;
|
}
|
|
public void setParam_cap_low(double param_cap_low) {
|
this.param_cap_low = param_cap_low;
|
}
|
|
public double getParam_charge_curr_low() {
|
return param_charge_curr_low;
|
}
|
|
public void setParam_charge_curr_low(double param_charge_curr_low) {
|
this.param_charge_curr_low = param_charge_curr_low;
|
}
|
|
public double getParam_charge_cap_low() {
|
return param_charge_cap_low;
|
}
|
|
public void setParam_charge_cap_low(double param_charge_cap_low) {
|
this.param_charge_cap_low = param_charge_cap_low;
|
}
|
|
public double getParam_online_vol_recover() {
|
return param_online_vol_recover;
|
}
|
|
public void setParam_online_vol_recover(double param_online_vol_recover) {
|
this.param_online_vol_recover = param_online_vol_recover;
|
}
|
|
public int getParam_module_address() {
|
return param_module_address;
|
}
|
|
public void setParam_module_address(int param_module_address) {
|
this.param_module_address = param_module_address;
|
}
|
|
public int getOp_cmd() {
|
return op_cmd;
|
}
|
|
public void setOp_cmd(int op_cmd) {
|
this.op_cmd = op_cmd;
|
}
|
|
public int getParam_junheng_model() {
|
return param_junheng_model;
|
}
|
|
public void setParam_junheng_model(int param_junheng_model) {
|
this.param_junheng_model = param_junheng_model;
|
}
|
|
public int getParam_datasource() {
|
return param_datasource;
|
}
|
|
public void setParam_datasource(int param_datasource) {
|
this.param_datasource = param_datasource;
|
}
|
|
public int getParam_res_args() {
|
return param_res_args;
|
}
|
|
public void setParam_res_args(int param_res_args) {
|
this.param_res_args = param_res_args;
|
}
|
|
|
|
public int getParam_tmp_high() {
|
return param_tmp_high;
|
}
|
|
public void setParam_tmp_high(int param_tmp_high) {
|
this.param_tmp_high = param_tmp_high;
|
}
|
|
public double getParam_res_high() {
|
return param_res_high;
|
}
|
|
public void setParam_res_high(double param_res_high) {
|
this.param_res_high = param_res_high;
|
}
|
|
@Override
|
public String toString() {
|
return "LD_param [cmd=" + cmd + ", cmd_addr=" + cmd_addr + ", cmd_addr_back=" + cmd_addr_back + ", dataCount="
|
+ dataCount + ", op_cmd=" + op_cmd + ", param_teststart_batt_num=" + param_teststart_batt_num
|
+ ", param_cap=" + param_cap + ", param_discharge_curr=" + param_discharge_curr
|
+ ", param_mon_curr_high=" + param_mon_curr_high + ", param_charge_curr=" + param_charge_curr
|
+ ", param_mon_curr_low=" + param_mon_curr_low + ", param_online_vol=" + param_online_vol
|
+ ", param_charge_curr_low=" + param_charge_curr_low + ", param_charge_cap_low=" + param_charge_cap_low
|
+ ", param_online_vol_recover=" + param_online_vol_recover + ", param_module_address="
|
+ param_module_address + ", param_junheng_model=" + param_junheng_model + ", param_cap_low="
|
+ param_cap_low + ", param_datasource=" + param_datasource + ", param_res_args=" + param_res_args
|
+ ", param_tmp_high=" + param_tmp_high + ", param_res_high=" + param_res_high + "]";
|
}
|
|
public BatchRead<Integer> createLDDisChargeParam(MyModbusMaster master) {
|
int offset = MyModBusCom.LD_PARM_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 putLDDisChargeParamBatchResult(BatchResults<Integer> res) {
|
if(null != res) {
|
int index = 0;
|
|
this.param_teststart_batt_num = res.getIntValue(index++);
|
this.param_cap = res.getIntValue(index++);
|
this.param_discharge_curr = (double)res.getIntValue(index++)*0.001;
|
this.param_mon_curr_low = (double)res.getIntValue(index++)*0.001;
|
this.param_charge_curr = (double)res.getIntValue(index++)*0.001;
|
this.param_mon_curr_high= (double)res.getIntValue(index++)*0.001;
|
this.param_online_vol = (double)res.getIntValue(index++)*0.01;
|
this.param_charge_curr_low = (double)res.getIntValue(index++)*0.001;
|
|
this.param_charge_cap_low = res.getIntValue(index++);
|
this.param_online_vol_recover = (double)res.getIntValue(index++)*0.01;
|
this.param_module_address = res.getIntValue(index++);
|
this.param_junheng_model = res.getIntValue(index++);
|
this.param_cap_low = (double)res.getIntValue(index++)*0.1;
|
this.param_datasource = res.getIntValue(index++);
|
this.param_res_args = res.getIntValue(index++);
|
this.param_tmp_high = res.getIntValue(index++);
|
this.param_res_high = (double)res.getIntValue(index++)*0.1;
|
}
|
return false;
|
}
|
|
public boolean setUpDisChargeParam(MyModbusMaster master) {
|
int offset = MyModBusCom.LD_PARM_ADDR;
|
int index = offset;
|
|
boolean flag = MyModbusUtils.writeHoldingRegister(index++, this.param_teststart_batt_num, DataType.TWO_BYTE_INT_UNSIGNED, master); //²âÊÔÆðʼµç³ØÐòºÅ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_cap, DataType.TWO_BYTE_INT_UNSIGNED, master); //±ê³ÆÈÝÁ¿
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_discharge_curr*1000, DataType.TWO_BYTE_INT_UNSIGNED, master); //·ÅµçµçÁ÷
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_mon_curr_low*1000, DataType.TWO_BYTE_INT_UNSIGNED, master); //µ¥ÌåÏÂÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_charge_curr*1000, DataType.TWO_BYTE_INT_UNSIGNED, master); //³äµçµçÁ÷
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_mon_curr_high*1000, DataType.TWO_BYTE_INT_UNSIGNED, master); //µ¥ÌåÉÏÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_online_vol*100, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÔÚÏßµçѹ·§Öµ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_charge_curr_low*1000, DataType.TWO_BYTE_INT_UNSIGNED, master); //³äµçµçÁ÷ÏÂÏÞ·§Öµ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_charge_cap_low, DataType.TWO_BYTE_INT_UNSIGNED, master); //³äµçÈÝÁ¿ÏÂÏÞÂÊ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_online_vol_recover*100, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÔÚÏßµçѹ»Ö¸´·§Öµ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_module_address, DataType.TWO_BYTE_INT_UNSIGNED, master); //Ä£¿éµØÖ·
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_junheng_model, DataType.TWO_BYTE_INT_UNSIGNED, master); //¾ùºâ¹¦ÄÜÆôÍ£
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_cap_low*10, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÈÝÁ¿ÏÂÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_datasource, DataType.TWO_BYTE_INT_UNSIGNED, master); //Êý¾ÝÀ´Ô´
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_res_args, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÄÚ×è²âÊÔϵÊý
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_tmp_high, DataType.TWO_BYTE_INT_UNSIGNED, master); //ζÈÉÏÏÞ
|
flag = flag&MyModbusUtils.writeHoldingRegister(index++, this.param_res_high*10, DataType.TWO_BYTE_INT_UNSIGNED, master); //ÄÚ×èÉÏÏÞ
|
|
return flag;
|
}
|
|
/**
|
*
|
* @param master
|
* @param regAddr
|
* @param controlvalue
|
* @return
|
*/
|
public boolean controlLDcontrol(MyModbusMaster master, int regAddr, int controlvalue) {
|
return MyModbusUtils.writeHoldingRegister(regAddr, controlvalue, DataType.TWO_BYTE_INT_UNSIGNED, master);
|
}
|
|
|
}
|