Program Listing for File AInput7Relay2Module.hpp
↰ Return to documentation for file (doc/include/AInput7Relay2Module.hpp
)
/****************************************************************************
* @defgroup PackageName Modules
* @file AInput7Relay2Module.hpp
* @brief
* @author info@pickdata.net
***************************************************************************/
#ifndef AINPUT7RELAY2_MODULE_HPP_
#define AINPUT7RELAY2_MODULE_HPP_
#include <cstdint>
#include "AInput7Relay2Module.h"
#include "Module.hpp"
// Forward declaration
class RelayFunctions;
class AnalogInputFunctions;
class AInput7Relay2Module : public Module {
friend class AInput7Relay2Napi;
protected:
RelayFunctions* relays;
AnalogInputFunctions* analogInputs;
EmodRet initFunctions();
uint8_t getNumAnalogInputs();
// Needed for bindings
uint8_t getInputFunctsOffsetIdAI();
public:
// Constants
static constexpr uint16_t kAnalogInput1 = AInput7Relay2Module_INPUT01;
static constexpr uint16_t kAnalogInput2 = AInput7Relay2Module_INPUT02;
static constexpr uint16_t kAnalogInput3 = AInput7Relay2Module_INPUT03;
static constexpr uint16_t kAnalogInput4 = AInput7Relay2Module_INPUT04;
static constexpr uint16_t kAnalogInput5 = AInput7Relay2Module_INPUT05;
static constexpr uint16_t kAnalogInput6 = AInput7Relay2Module_INPUT06;
static constexpr uint16_t kAnalogInput7 = AInput7Relay2Module_INPUT07;
static constexpr uint16_t kAnalogInputAll = AInput7Relay2Module_ALL_INPUT;
static constexpr uint8_t kRelay1 = AInput7Relay2Module_RELAY1;
static constexpr uint8_t kRelay2 = AInput7Relay2Module_RELAY2;
static constexpr uint8_t kRelayAll = AInput7Relay2Module_ALL_RELAY;
static constexpr uint8_t kNumberOfAnalogInputs = AInput7Relay2Module_NUMBER_OF_AI_INPUTS;
static constexpr uint8_t kNumberOfRelays = AInput7Relay2Module_NUMBER_OF_RELAYS;
static constexpr uint8_t kIdFunctionInput1 = AInput7Relay2Module_idFunctionINPUT01;
static constexpr uint8_t kIdFunctionInput2 = AInput7Relay2Module_idFunctionINPUT02;
static constexpr uint8_t kIdFunctionInput3 = AInput7Relay2Module_idFunctionINPUT03;
static constexpr uint8_t kIdFunctionInput4 = AInput7Relay2Module_idFunctionINPUT04;
static constexpr uint8_t kIdFunctionInput5 = AInput7Relay2Module_idFunctionINPUT05;
static constexpr uint8_t kIdFunctionInput6 = AInput7Relay2Module_idFunctionINPUT06;
static constexpr uint8_t kIdFunctionInput7 = AInput7Relay2Module_idFunctionINPUT07;
static constexpr uint16_t kMaxADC = AInput7Relay2Module_MAX_ADC;
static constexpr uint8_t kCfgVoltage = AInput7Relay2Module_CFG_VOLTAGE;
static constexpr uint8_t kCfgCurrent = AInput7Relay2Module_CFG_CURRENT;
static constexpr float kMaxVoltage = AInput7Relay2Module_MAX_VOLTAGE;
static constexpr float kMaxCurrent = AInput7Relay2Module_MAX_CURRENT;
// Constructor, destructor and init methods
AInput7Relay2Module();
~AInput7Relay2Module();
EmodRet init(const AInput7Relay2ModuleCallback_Type callback_func = nullptr, void* const callback_context = nullptr, const uint8_t variant = 1);
EmodRet init(const uint8_t variant);
// AI methods
EmodRet configSampleRate(const uint32_t ms_period);
EmodRet configInput(const uint16_t voltage_input_mask);
EmodRet getInputConfig(uint16_t* config);
EmodRet getAnalogInput(const uint16_t input_number, float* data);
EmodRet getAllAnalogInput(float data[kNumberOfAnalogInputs]);
// Relays methods
EmodRet configPulseWidth(const uint8_t relay_mask, const uint32_t width_ms);
EmodRet configAllPulseWidth(const uint32_t width_ms);
EmodRet activate(const uint8_t relay_mask);
EmodRet deactivate(const uint8_t relay_mask);
EmodRet activateAll(void);
EmodRet deactivateAll(void);
EmodRet getRelayStatus(const uint8_t relay_mask, uint8_t* status);
EmodRet getAllRelayStatus(uint8_t* status);
// Callback methods
EmodRet configEventAtTimeInterval(const uint32_t time_interval, const uint32_t event_mask = AInput7Relay2Module::kAnalogInputAll);
EmodRet configEventOnValueChange(const uint32_t threshold, const uint32_t event_mask = AInput7Relay2Module::kAnalogInputAll);
EmodRet configEventWithinRange(const uint32_t low_limit, const uint32_t high_limit, const uint32_t event_mask = AInput7Relay2Module::kAnalogInputAll);
EmodRet configEventOutOfRange(const uint32_t low_limit, const uint32_t high_limit, const uint32_t event_mask = AInput7Relay2Module::kAnalogInputAll);
EmodRet resetEventConfig(void);
// Support methods
uint16_t voltageToSamples(const float voltage);
uint16_t currentToSamples(const float current);
float samplesToVoltage(const uint16_t samples);
float samplesToCurrent(const uint16_t samples);
};
#endif // AINPUT7RELAY2_MODULE_HPP_