Lock position fix
This commit is contained in:
@@ -22,18 +22,18 @@ remoteIO::~remoteIO()
|
|||||||
|
|
||||||
const bool remoteIO::setOut(const channel_t ch, const bool value)
|
const bool remoteIO::setOut(const channel_t ch, const bool value)
|
||||||
{
|
{
|
||||||
auto lock = m_bus.getLock();
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
auto lock = m_bus.getLock();
|
||||||
LOG_DEBUG("Write Channel", ch, "->", value ? "True" : "False");
|
LOG_DEBUG("Write Channel", ch, "->", value ? "True" : "False");
|
||||||
return m_bus.writeCoil(m_address, REG_COILS + ch, value);
|
return m_bus.writeCoil(m_address, REG_COILS + ch, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool remoteIO::toggleOut(const channel_t ch)
|
const bool remoteIO::toggleOut(const channel_t ch)
|
||||||
{
|
{
|
||||||
auto lock = m_bus.getLock();
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
auto lock = m_bus.getLock();
|
||||||
std::vector<bool> value;
|
std::vector<bool> value;
|
||||||
if (!m_bus.readCoils(m_address, REG_COILS + ch, 1, value))
|
if (!m_bus.readCoils(m_address, REG_COILS + ch, 1, value))
|
||||||
return false;
|
return false;
|
||||||
@@ -43,18 +43,18 @@ const bool remoteIO::toggleOut(const channel_t ch)
|
|||||||
|
|
||||||
const bool remoteIO::setOutPort(const std::vector<bool> values)
|
const bool remoteIO::setOutPort(const std::vector<bool> values)
|
||||||
{
|
{
|
||||||
auto lock = m_bus.getLock();
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
auto lock = m_bus.getLock();
|
||||||
LOG_DEBUG("Write Port", CH_MAX);
|
LOG_DEBUG("Write Port", CH_MAX);
|
||||||
return m_bus.writeCoils(m_address, CH_MAX, values);
|
return m_bus.writeCoils(m_address, CH_MAX, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool remoteIO::getOut(const channel_t ch, bool &value)
|
const bool remoteIO::getOut(const channel_t ch, bool &value)
|
||||||
{
|
{
|
||||||
auto lock = m_bus.getLock();
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
auto lock = m_bus.getLock();
|
||||||
std::vector<bool> values;
|
std::vector<bool> values;
|
||||||
if (!m_bus.readCoils(m_address, REG_COILS + ch, 1, values))
|
if (!m_bus.readCoils(m_address, REG_COILS + ch, 1, values))
|
||||||
return false;
|
return false;
|
||||||
@@ -65,18 +65,18 @@ const bool remoteIO::getOut(const channel_t ch, bool &value)
|
|||||||
|
|
||||||
const bool remoteIO::getOutPort(std::vector<bool> &values)
|
const bool remoteIO::getOutPort(std::vector<bool> &values)
|
||||||
{
|
{
|
||||||
auto lock = m_bus.getLock();
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
auto lock = m_bus.getLock();
|
||||||
LOG_DEBUG("Read Port", CH_MAX);
|
LOG_DEBUG("Read Port", CH_MAX);
|
||||||
return m_bus.readCoils(m_address, REG_COILS, 8, values);
|
return m_bus.readCoils(m_address, REG_COILS, 8, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool remoteIO::getIn(const channel_t input, bool &value)
|
const bool remoteIO::getIn(const channel_t input, bool &value)
|
||||||
{
|
{
|
||||||
auto lock = m_bus.getLock();
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
auto lock = m_bus.getLock();
|
||||||
std::vector<bool> values;
|
std::vector<bool> values;
|
||||||
if (!m_bus.readInputs(m_address, REG_INPUT + input, 1, values))
|
if (!m_bus.readInputs(m_address, REG_INPUT + input, 1, values))
|
||||||
return false;
|
return false;
|
||||||
@@ -87,9 +87,9 @@ const bool remoteIO::getIn(const channel_t input, bool &value)
|
|||||||
|
|
||||||
const bool remoteIO::getInPort(std::vector<bool> &values)
|
const bool remoteIO::getInPort(std::vector<bool> &values)
|
||||||
{
|
{
|
||||||
auto lock = m_bus.getLock();
|
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
auto lock = m_bus.getLock();
|
||||||
LOG_DEBUG("Read Inputs", CH_MAX);
|
LOG_DEBUG("Read Inputs", CH_MAX);
|
||||||
return m_bus.readInputs(m_address, REG_INPUT, CH_MAX, values);
|
return m_bus.readInputs(m_address, REG_INPUT, CH_MAX, values);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user