Program Listing for File DInput5Relay2Module.h

Return to documentation for file (doc/include/DInput5Relay2Module.h)

#ifndef DINPUT5RELAY2_MODULE_H_
#define DINPUT5RELAY2_MODULE_H_

#include <stdint.h>

#include "EmodRet.hpp"

#ifdef __cplusplus
extern "C" {
#endif

#define DInput5Relay2Module_INPUT01 0x0001
#define DInput5Relay2Module_INPUT02 0x0002
#define DInput5Relay2Module_INPUT03 0x0004
#define DInput5Relay2Module_INPUT04 0x0008
#define DInput5Relay2Module_INPUT05 0x0010
#define DInput5Relay2Module_ALL_INPUT 0x001f

#define DInput5Relay2Module_RELAY1 0x01
#define DInput5Relay2Module_RELAY2 0x02
#define DInput5Relay2Module_ALL_RELAY 0x03

#define DInput5Relay2Module_NUMBER_OF_DI_INPUTS 5
#define DInput5Relay2Module_NUMBER_OF_RELAYS 2

#define DInput5Relay2Module_MODE_PRETRIGGER_TIME 0x00000000
#define DInput5Relay2Module_MODE_PULSE_COUNTER 0x00000001
#define DInput5Relay2Module_MODE_WIDTH_COUNTER 0x00000002

#define DInput5Relay2Module_idFunctionINPUTS 5
#define DInput5Relay2Module_idFunctionCOUNTER01 7
#define DInput5Relay2Module_idFunctionCOUNTER02 8
#define DInput5Relay2Module_idFunctionCOUNTER03 9
#define DInput5Relay2Module_idFunctionCOUNTER04 10
#define DInput5Relay2Module_idFunctionCOUNTER05 11

struct DInput5Relay2ModuleStruct;
typedef struct DInput5Relay2ModuleStruct DInput5Relay2Module_t;
typedef void (*DInput5Relay2ModuleCallback_Type)(const uint8_t* data, uint16_t datalen, uint8_t idFunction, void* ctx);

DInput5Relay2Module_t* DInput5Relay2Module_create();
void DInput5Relay2Module_destroy(DInput5Relay2Module_t* module);

EmodRet DInput5Relay2Module_init(DInput5Relay2Module_t* module, const DInput5Relay2ModuleCallback_Type callback, void* context);
EmodRet DInput5Relay2Module_init_v(DInput5Relay2Module_t* module, const DInput5Relay2ModuleCallback_Type callback, void* context, uint8_t variant);

// DI methods
EmodRet DInput5Relay2Module_getStatus(DInput5Relay2Module_t* module, const uint16_t input_number, uint8_t* status);
EmodRet DInput5Relay2Module_getAllStatus(DInput5Relay2Module_t* module, uint8_t status[DInput5Relay2Module_NUMBER_OF_DI_INPUTS]);
EmodRet DInput5Relay2Module_getPulseCount(DInput5Relay2Module_t* module, const uint16_t input_number, uint32_t* count);
EmodRet DInput5Relay2Module_getAllPulseCount(DInput5Relay2Module_t* module, uint32_t counts[DInput5Relay2Module_NUMBER_OF_DI_INPUTS]);
EmodRet DInput5Relay2Module_resetPulseCount(DInput5Relay2Module_t* module, uint16_t input_number);
EmodRet DInput5Relay2Module_resetAllPulseCount(DInput5Relay2Module_t* module);
EmodRet DInput5Relay2Module_getPulseWidth(DInput5Relay2Module_t* module, const uint16_t input_number, uint32_t* width);
EmodRet DInput5Relay2Module_getAllPulseWidth(DInput5Relay2Module_t* module, uint32_t widths[DInput5Relay2Module_NUMBER_OF_DI_INPUTS]);

// Relays methods
EmodRet DInput5Relay2Module_configPulseWidth(DInput5Relay2Module_t* module, const uint8_t relay_mask, const uint32_t width_ms);
EmodRet DInput5Relay2Module_activate(DInput5Relay2Module_t* module, const uint8_t relay_mask);
EmodRet DInput5Relay2Module_deactivate(DInput5Relay2Module_t* module, const uint8_t relay_mask);
EmodRet DInput5Relay2Module_activateAll(DInput5Relay2Module_t* module);
EmodRet DInput5Relay2Module_deactivateAll(DInput5Relay2Module_t* module);
EmodRet DInput5Relay2Module_getRelayStatus(DInput5Relay2Module_t* module, const uint8_t relay_mask, uint8_t* status);
EmodRet DInput5Relay2Module_getAllRelayStatus(DInput5Relay2Module_t* module, uint8_t* status);

// Callback methods
EmodRet DInput5Relay2Module_configEventAtTimeInterval(DInput5Relay2Module_t* module, const uint16_t time_interval, const uint32_t event_mask);
EmodRet DInput5Relay2Module_switchToMode(DInput5Relay2Module_t* module, const uint16_t input_number,
                                         uint32_t mode);  // Callback mode. To be initialized in the beginning
EmodRet DInput5Relay2Module_configEventOnNewData(DInput5Relay2Module_t* module);
EmodRet DInput5Relay2Module_configEventOnValueChange(DInput5Relay2Module_t* module, uint32_t event_mask, uint32_t threshold);
EmodRet DInput5Relay2Module_resetEventConfig(DInput5Relay2Module_t* module);

#ifdef __cplusplus
}
#endif

#endif  // DINPUT5RELAY2_MODULE_H_