package com.data;
|
|
import java.util.Date;
|
|
import com.modbus.data.MyModbusMaster;
|
import com.modbus.data.MyModbusUtils;
|
import com.serotonin.modbus4j.BatchRead;
|
import com.serotonin.modbus4j.BatchResults;
|
import com.serotonin.modbus4j.code.DataType;
|
|
public class Central_RT_Data {
|
|
private int dev_id; // 'É豸id',
|
private Date record_time; //'¸üÐÂʱ¼ä',
|
|
private int switch_close; // '¿ª¹ØºÏբ״̬',
|
private int switch_open; // '¿ª¹Ø·Öբ״̬',
|
private int switch_fault; // '¿ª¹Ø¹ÊÕÏ״̬',
|
private float panel_vol ; // '½øÏ߯Áµçѹ',
|
private float panel_curr ; // '½øÏ߯ÁµçÁ÷',
|
|
private String note; //'±¸ÓÃ',
|
|
public BatchRead<Integer> createBatchRead(MyModbusMaster master) {
|
BatchRead<Integer> batch = new BatchRead<Integer>();
|
batch.addLocator(0,MyModbusUtils.createInputLocator(1,master)); //'1ºÅ2500A½øÏ߯Á¿ª¹ØºÏբ״̬',
|
batch.addLocator(1,MyModbusUtils.createInputLocator(2,master)); //'1ºÅ2500A½øÏ߯Á¿ª¹Ø·Öբ״̬'
|
batch.addLocator(2,MyModbusUtils.createInputLocator(3, master)); //'1ºÅ2500A½øÏ߯Á¿ª¹Ø¹ÊÕÏ״̬',
|
|
batch.addLocator(3,MyModbusUtils.createBaseLocator(1,DataType.TWO_BYTE_INT_SIGNED,master)); //'AÅŵçÁ÷',
|
if(10001 == dev_id) {
|
batch.addLocator(4,MyModbusUtils.createBaseLocator(2,DataType.TWO_BYTE_INT_SIGNED,master)); //'AÅŵçѹ',
|
}
|
|
|
return batch;
|
}
|
|
public void putBatchResult(BatchResults<Integer> res) {
|
if(null != res) {
|
switch_close = MyModbusUtils.readBooleanToInt(res.getValue(0)); // '¿ª¹ØºÏբ״̬',
|
switch_open = MyModbusUtils.readBooleanToInt(res.getValue(1)); // '¿ª¹Ø·Öբ״̬',
|
switch_fault = MyModbusUtils.readBooleanToInt(res.getValue(2)); // '¿ª¹Ø¹ÊÕÏ״̬',
|
if(10001 == dev_id) {
|
panel_vol = MyModbusUtils.readShortToInt(res.getValue(3)); // '½øÏ߯Áµçѹ',
|
panel_curr = MyModbusUtils.readShortToInt(res.getValue(4)); // '½øÏ߯ÁµçÁ÷',
|
}else {
|
panel_curr = MyModbusUtils.readShortToInt(res.getValue(3)); // '½øÏ߯ÁµçÁ÷',
|
}
|
}
|
}
|
|
|
public Central_RT_Data() {
|
|
}
|
|
public Central_RT_Data(int dev_id) {
|
this.dev_id = dev_id;
|
}
|
|
public int getDev_id() {
|
return dev_id;
|
}
|
public void setDev_id(int dev_id) {
|
this.dev_id = dev_id;
|
}
|
public Date getRecord_time() {
|
return record_time;
|
}
|
public void setRecord_time(Date record_time) {
|
this.record_time = record_time;
|
}
|
public int getSwitch_close() {
|
return switch_close;
|
}
|
public void setSwitch_close(int switch_close) {
|
this.switch_close = switch_close;
|
}
|
public int getSwitch_open() {
|
return switch_open;
|
}
|
public void setSwitch_open(int switch_open) {
|
this.switch_open = switch_open;
|
}
|
public int getSwitch_fault() {
|
return switch_fault;
|
}
|
public void setSwitch_fault(int switch_fault) {
|
this.switch_fault = switch_fault;
|
}
|
public float getPanel_vol() {
|
return panel_vol;
|
}
|
public void setPanel_vol(float panel_vol) {
|
this.panel_vol = panel_vol;
|
}
|
public float getPanel_curr() {
|
return panel_curr;
|
}
|
public void setPanel_curr(float panel_curr) {
|
this.panel_curr = panel_curr;
|
}
|
public String getNote() {
|
return note;
|
}
|
public void setNote(String note) {
|
this.note = note;
|
}
|
@Override
|
public String toString() {
|
return "Central_RT_Data [dev_id=" + dev_id + ", record_time=" + record_time + ", switch_close=" + switch_close
|
+ ", switch_open=" + switch_open + ", switch_fault=" + switch_fault + ", panel_vol=" + panel_vol
|
+ ", panel_curr=" + panel_curr + ", note=" + note + "]";
|
}
|
}
|