Program Listing for File AInput12Module.hpp

Return to documentation for file (doc/include/AInput12Module.hpp)

/****************************************************************************
 * @defgroup PackageName Modules
 * @file DInputModule.hpp
 * @brief
 * @author info@pickdata.net
 ***************************************************************************/
#ifndef AINPUT12_MODULE_HPP_
#define AINPUT12_MODULE_HPP_

#include "AInput12Module.h"
#include "Module.hpp"

// Forward declaration
class AnalogInputFunctions;

class AInput12Module : public Module {
    friend class AInput12Napi;

protected:
    AnalogInputFunctions* analogInputs;
    EmodRet initFunctions();
    uint8_t getInputsOffsetId();
    uint8_t getNumAnalogInputs();

public:
    // Constants
    static constexpr uint16_t AI_INPUT01 = AInput12Module_INPUT01;
    static constexpr uint16_t AI_INPUT02 = AInput12Module_INPUT02;
    static constexpr uint16_t AI_INPUT03 = AInput12Module_INPUT03;
    static constexpr uint16_t AI_INPUT04 = AInput12Module_INPUT04;
    static constexpr uint16_t AI_INPUT05 = AInput12Module_INPUT05;
    static constexpr uint16_t AI_INPUT06 = AInput12Module_INPUT06;
    static constexpr uint16_t AI_INPUT07 = AInput12Module_INPUT07;
    static constexpr uint16_t AI_INPUT08 = AInput12Module_INPUT08;
    static constexpr uint16_t AI_INPUT09 = AInput12Module_INPUT09;
    static constexpr uint16_t AI_INPUT10 = AInput12Module_INPUT10;
    static constexpr uint16_t AI_INPUT11 = AInput12Module_INPUT11;
    static constexpr uint16_t AI_INPUT12 = AInput12Module_INPUT12;
    static constexpr uint16_t AI_ALL_INPUT = AInput12Module_ALL_INPUT;

    static constexpr uint8_t NUMBER_OF_AI_INPUTS = AInput12Module_NUMBER_OF_AI_INPUTS;

    static constexpr uint16_t MAX_ADC = AInput12Module_MAX_ADC;

    static constexpr uint8_t CFG_VOLTAGE = AInput12Module_CFG_VOLTAGE;
    static constexpr uint8_t CFG_CURRENT = AInput12Module_CFG_CURRENT;

    static constexpr float MAX_VOLTAGE = AInput12Module_MAX_VOLTAGE;
    static constexpr float MAX_CURRENT = AInput12Module_MAX_CURRENT;

    // Constructor, destructor and init methods
    AInput12Module();
    ~AInput12Module();

    EmodRet init(const AInput12ModuleCallback_Type callback_func = nullptr, void* const callback_context = nullptr, const uint8_t variant = 1);
    EmodRet init(const uint8_t variant);


    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 AI_INPUT_number, float* data);

    EmodRet getAllAnalogInput(float data[NUMBER_OF_AI_INPUTS]);

    // Callback methods

    EmodRet configEventAtTimeInterval(const uint32_t time_interval, const uint32_t event_mask = AInput12Module::AI_ALL_INPUT);

    EmodRet configEventOnValueChange(const uint32_t threshold, const uint32_t event_mask = AInput12Module::AI_ALL_INPUT);

    EmodRet configEventWithinRange(const uint32_t low_limit, const uint32_t high_limit, const uint32_t event_mask = AInput12Module::AI_ALL_INPUT);

    EmodRet configEventOutOfRange(const uint32_t low_limit, const uint32_t high_limit, const uint32_t event_mask = AInput12Module::AI_ALL_INPUT);

    EmodRet resetEventConfig(void);

    // Support methods

    uint16_t voltageToSamples(float voltage);

    uint16_t currentToSamples(float current);

    float samplesToVoltage(uint16_t samples);

    float samplesToCurrent(uint16_t samples);
};

#endif  // AINPUT12_MODULE_HPP_