Program Listing for File Module.hpp
↰ Return to documentation for file (doc/include/Module.hpp
)
#ifndef MODULE_HPP_
#define MODULE_HPP_
#include <vector>
#include "EmodCommon.hpp"
#include "EmodRet.hpp"
// Module function callback type definition
typedef void (*ModuleCallback_Type)(const uint8_t* data, const uint16_t data_len, const uint8_t id_function, void* const ctx);
enum EventTriggerCondition {
noCondition = 0x0000,
conditionTimeOut = 0x0001,
conditionNewData = 0x0002,
conditionValChange = 0x0004,
conditionInRange = 0x0008,
conditionOutRange = 0x0010,
conditionForceSend = 0x0020,
ackRequested = 0x2000
};
// Forward declarations
class Controller;
class BusIdent;
class BusParamConf;
class Module {
private:
BusParamConf* function_params;
ModuleCallback_Type callback_func;
void* callback_context;
bool polling_is_disabled;
Controller& controller;
BusIdent* ident;
int8_t id_bus;
EmodRet checkConfigEvent(const std::vector<int>& id_funcs, const bool buffer_type = false);
EmodRet setAndSubscribeEvent(const EventTriggerCondition condition, const std::vector<int>& id_funcs, const uint32_t param_1 = 0,
const uint32_t param_2 = 0);
EmodRet sendConfigEvent(const std::vector<int>& id_funcs, const bool request_funcs);
protected:
Module();
~Module();
EmodRet init(const ModuleType module_type, const ModuleCallback_Type& callback_func, void* const callback_context, const uint8_t module_variant = 1);
EmodRet initFunctionParams(const bool unsubscribe = false);
inline int8_t getIdBus() { return id_bus; }
inline void setIdBus(const int8_t id_bus) { this->id_bus = id_bus; }
EmodRet configEvent(const EventTriggerCondition condition, const std::vector<int>& id_funcs, const uint32_t param_1 = 0, const uint32_t param_2 = 0);
EmodRet configEvent(const EventTriggerCondition condition, const uint16_t mask, const uint8_t max_id, const uint8_t id_offset, const uint32_t param_1 = 0,
const uint32_t param_2 = 0);
EmodRet resetEventConfig(void);
public:
static uint8_t maskToInput(const uint16_t input_mask, const uint8_t max);
static std::vector<int> maskToInputs(const uint16_t mask);
void whoIs();
};
#endif // MODULE_HPP_