Program Listing for File DInput10Module.hpp

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

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

#include "DInput10Module.h"
#include "Module.hpp"

// Forward declaration
class DigitalInputFunctions;

class DInput10Module : public Module {
    friend class DInput10Napi;

protected:
    DigitalInputFunctions* digitalInputs;
    EmodRet initFunctions();
    // Needed for bindings
    uint8_t getInputFunctsOffsetIdDI();
    uint8_t getFunctsOffsetIdDI();

public:
    // Constants
    static constexpr uint16_t kDigitalInput1 = DInput10Module_INPUT01;
    static constexpr uint16_t kDigitalInput2 = DInput10Module_INPUT02;
    static constexpr uint16_t kDigitalInput3 = DInput10Module_INPUT03;
    static constexpr uint16_t kDigitalInput4 = DInput10Module_INPUT04;
    static constexpr uint16_t kDigitalInput5 = DInput10Module_INPUT05;
    static constexpr uint16_t kDigitalInput6 = DInput10Module_INPUT06;
    static constexpr uint16_t kDigitalInput7 = DInput10Module_INPUT07;
    static constexpr uint16_t kDigitalInput8 = DInput10Module_INPUT08;
    static constexpr uint16_t kDigitalInput9 = DInput10Module_INPUT09;
    static constexpr uint16_t kDigitalInput10 = DInput10Module_INPUT10;
    static constexpr uint16_t kDigitalInputAll = DInput10Module_ALL_INPUT;

    static constexpr uint8_t kNumberOfDigitalInputs = DInput10Module_NUMBER_OF_DI_INPUTS;

    static constexpr uint32_t kPretriggeredTimeMode = DInput10Module_MODE_PRETRIGGER_TIME;
    static constexpr uint32_t kPulseCounterMode = DInput10Module_MODE_PULSE_COUNTER;
    static constexpr uint32_t kWidthCounterMode = DInput10Module_MODE_WIDTH_COUNTER;

    static constexpr uint8_t kIdFunctionInputs = DInput10Module_idFunctionINPUTS;
    static constexpr uint8_t kIdFunctionCounter1 = DInput10Module_idFunctionCOUNTER01;
    static constexpr uint8_t kIdFunctionCounter2 = DInput10Module_idFunctionCOUNTER02;
    static constexpr uint8_t kIdFunctionCounter3 = DInput10Module_idFunctionCOUNTER03;
    static constexpr uint8_t kIdFunctionCounter4 = DInput10Module_idFunctionCOUNTER04;
    static constexpr uint8_t kIdFunctionCounter5 = DInput10Module_idFunctionCOUNTER05;
    static constexpr uint8_t kIdFunctionCounter6 = DInput10Module_idFunctionCOUNTER06;
    static constexpr uint8_t kIdFunctionCounter7 = DInput10Module_idFunctionCOUNTER07;
    static constexpr uint8_t kIdFunctionCounter8 = DInput10Module_idFunctionCOUNTER08;
    static constexpr uint8_t kIdFunctionCounter9 = DInput10Module_idFunctionCOUNTER09;
    static constexpr uint8_t kIdFunctionCounter10 = DInput10Module_idFunctionCOUNTER10;

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

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

    EmodRet init(const uint8_t variant);

    // DI methods

    EmodRet getStatus(const uint16_t DI_INPUT_mask, uint8_t* status, bool* new_data = nullptr);

    EmodRet getAllStatus(uint8_t status[kNumberOfDigitalInputs], bool* new_data = nullptr);

    EmodRet setPulseFilterTime(const uint16_t DI_INPUT_mask, const uint32_t ms_time);

    EmodRet setAllPulseFilterTime(const uint32_t ms_time);

    EmodRet getPulseFilterTime(const uint16_t DI_INPUT_mask, uint32_t* ms_time);

    EmodRet getAllPulseFilterTime(uint32_t ms_times[kNumberOfDigitalInputs]);

    EmodRet getPulseCount(const uint16_t DI_INPUT_mask, uint32_t* count);

    EmodRet getAllPulseCount(uint32_t counts[kNumberOfDigitalInputs]);

    EmodRet resetPulseCount(const uint16_t DI_INPUT_mask);

    EmodRet resetAllPulseCount();

    EmodRet getPulseWidth(const uint16_t DI_INPUT_mask, uint32_t* width);

    EmodRet getAllPulseWidth(uint32_t widths[kNumberOfDigitalInputs]);

    // Callback methods

    EmodRet configEventAtTimeInterval(const uint32_t time_interval);

    EmodRet switchToMode(const uint16_t DI_INPUT_mask, const uint32_t mode);

    EmodRet configEventOnNewData();

    EmodRet configEventOnValueChange(const uint32_t threshold, const uint32_t event_mask = kDigitalInputAll);

    EmodRet resetEventConfig(void);
};

#endif  // DINPUT10_MODULE_HPP_