DigitalIO driver with dynamic channel count
This commit is contained in:
37
src/remoteIO.h
Normal file
37
src/remoteIO.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <DebugLog.h>
|
||||
#include <RS485_Driver.h>
|
||||
|
||||
class remoteIO
|
||||
{
|
||||
public:
|
||||
typedef enum {CH1, CH2, CH3, CH4, CH5, CH6, CH7, CH8, CH_MAX} channel_t;
|
||||
|
||||
private:
|
||||
const uint16_t REG_VERSION = 0x8000;
|
||||
const uint16_t REG_COILS = 0x0000;
|
||||
const uint16_t REG_INPUT = 0x0000;
|
||||
const uint16_t REG_ALLCOILS = 0x00FF;
|
||||
|
||||
public:
|
||||
remoteIO(const uint8_t address, drivers::MODBUS &bus);
|
||||
~remoteIO();
|
||||
|
||||
const bool setOut(const channel_t ch, const bool value);
|
||||
const bool toggleOut(const channel_t ch);
|
||||
const bool setOutPort(const std::vector<bool> values);
|
||||
|
||||
const bool getOut(const channel_t ch, bool &value);
|
||||
const bool getOutPort(std::vector<bool> &values);
|
||||
|
||||
const bool getIn(const channel_t input, bool &value);
|
||||
const bool getInPort(std::vector<bool> &values);
|
||||
|
||||
void resetAll(const bool value);
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
drivers::MODBUS &m_bus;
|
||||
const uint8_t m_address;
|
||||
};
|
||||
Reference in New Issue
Block a user