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 getNumAnalogInputs();

    // Needed for bindings
    uint8_t getInputFunctsOffsetIdAI();

public:
    // Constants
    static constexpr uint16_t kAnalogInput1 = AInput12Module_INPUT01;
    static constexpr uint16_t kAnalogInput2 = AInput12Module_INPUT02;
    static constexpr uint16_t kAnalogInput3 = AInput12Module_INPUT03;
    static constexpr uint16_t kAnalogInput4 = AInput12Module_INPUT04;
    static constexpr uint16_t kAnalogInput5 = AInput12Module_INPUT05;
    static constexpr uint16_t kAnalogInput6 = AInput12Module_INPUT06;
    static constexpr uint16_t kAnalogInput7 = AInput12Module_INPUT07;
    static constexpr uint16_t kAnalogInput8 = AInput12Module_INPUT08;
    static constexpr uint16_t kAnalogInput9 = AInput12Module_INPUT09;
    static constexpr uint16_t kAnalogInput10 = AInput12Module_INPUT10;
    static constexpr uint16_t kAnalogInput11 = AInput12Module_INPUT11;
    static constexpr uint16_t kAnalogInput12 = AInput12Module_INPUT12;
    static constexpr uint16_t kAnalogInputAll = AInput12Module_ALL_INPUT;

    static constexpr uint8_t kNumberOfAnalogInputs = AInput12Module_NUMBER_OF_AI_INPUTS;

    static constexpr uint16_t kMaxADC = AInput12Module_MAX_ADC;

    static constexpr uint8_t kCfgVoltage = AInput12Module_CFG_VOLTAGE;
    static constexpr uint8_t kCfgCurrent = AInput12Module_CFG_CURRENT;

    static constexpr float kMaxVoltage = AInput12Module_MAX_VOLTAGE;
    static constexpr float kMaxCurrent = 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[kNumberOfAnalogInputs]);

    // Callback methods

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

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

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

    EmodRet configEventOutOfRange(const uint32_t low_limit, const uint32_t high_limit, const uint32_t event_mask = AInput12Module::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  // AINPUT12_MODULE_HPP_