use of net.wimpi.modbus.util.BitVector in project openhab1-addons by openhab.
the class ModbusSerialMaster method readInputDiscretes.
// writeMultipleCoils
/**
* Reads a given number of input discrete states from the slave.
* <p/>
* Note that the number of bits in the bit vector will be
* forced to the number originally requested.
*
* @param unitid the slave unit id.
* @param ref the offset of the input discrete to start reading from.
* @param count the number of input discrete states to be read.
* @return a <tt>BitVector</tt> instance holding the received input discrete
* states.
* @throws ModbusException if an I/O error, a slave exception or
* a transaction error occurs.
*/
public synchronized BitVector readInputDiscretes(int unitid, int ref, int count) throws ModbusException {
m_ReadInputDiscretesRequest.setUnitID(unitid);
m_ReadInputDiscretesRequest.setReference(ref);
m_ReadInputDiscretesRequest.setBitCount(count);
m_Transaction.setRequest(m_ReadInputDiscretesRequest);
m_Transaction.execute();
BitVector bv = ((ReadInputDiscretesResponse) m_Transaction.getResponse()).getDiscretes();
bv.forceSize(count);
return bv;
}
use of net.wimpi.modbus.util.BitVector in project openhab1-addons by openhab.
the class ModbusTCPMaster method readInputDiscretes.
// writeMultipleCoils
/**
* Reads a given number of input discrete states from the slave.
* <p/>
* Note that the number of bits in the bit vector will be
* forced to the number originally requested.
*
* @param ref the offset of the input discrete to start reading from.
* @param count the number of input discrete states to be read.
* @return a <tt>BitVector</tt> instance holding the received input discrete
* states.
* @throws ModbusException if an I/O error, a slave exception or
* a transaction error occurs.
*/
public synchronized BitVector readInputDiscretes(int ref, int count) throws ModbusException {
m_ReadInputDiscretesRequest.setReference(ref);
m_ReadInputDiscretesRequest.setBitCount(count);
m_Transaction.setRequest(m_ReadInputDiscretesRequest);
m_Transaction.execute();
BitVector bv = ((ReadInputDiscretesResponse) m_Transaction.getResponse()).getDiscretes();
bv.forceSize(count);
return bv;
}
use of net.wimpi.modbus.util.BitVector in project openhab1-addons by openhab.
the class ModbusTCPMaster method readCoils.
// isReconnecting
/**
* Reads a given number of coil states from the slave.
* <p/>
* Note that the number of bits in the bit vector will be
* forced to the number originally requested.
*
* @param ref the offset of the coil to start reading from.
* @param count the number of coil states to be read.
* @return a <tt>BitVector</tt> instance holding the
* received coil states.
* @throws ModbusException if an I/O error, a slave exception or
* a transaction error occurs.
*/
public synchronized BitVector readCoils(int ref, int count) throws ModbusException {
m_ReadCoilsRequest.setReference(ref);
m_ReadCoilsRequest.setBitCount(count);
m_Transaction.setRequest(m_ReadCoilsRequest);
m_Transaction.execute();
BitVector bv = ((ReadCoilsResponse) m_Transaction.getResponse()).getCoils();
bv.forceSize(count);
return bv;
}
use of net.wimpi.modbus.util.BitVector in project openhab1-addons by openhab.
the class ReadInputDiscretesResponse method setBitCount.
// getBitCount
/**
* Sets the number of bits in this response.
*
* @param count the number of response bits as int.
*/
public void setBitCount(int count) {
m_BitCount = count;
m_Discretes = new BitVector(count);
// set correct length, without counting unitid and fc
setDataLength(m_Discretes.byteSize() + 1);
}
Aggregations