desarrollosconsejeria/placaSiatic/1.0-0/redrelaylibrary.h @ b9655064
b9655064 | Elisa | /*
|
|
* RedRelayLibrary
|
|||
* A C++ Library using HIDAPI to control
|
|||
* generic VUSB relay devices
|
|||
*
|
|||
* @author: Alejandro Antúnez Reino, SODITEC S.L
|
|||
*/
|
|||
#ifndef REDRELAYLIBRARY_H
|
|||
#define REDRELAYLIBRARY_H
|
|||
#include <hidapi/hidapi.h>
|
|||
#include <string.h>
|
|||
#include <bitset>
|
|||
#include <limits.h>
|
|||
enum RelayState {
|
|||
ON = 0xFD,
|
|||
OFF = 0xFF
|
|||
};
|
|||
enum RelayPort {
|
|||
PORT_ONE,
|
|||
PORT_TWO,
|
|||
PORT_THREE,
|
|||
PORT_FOUR,
|
|||
PORT_FIVE,
|
|||
PORT_SIX,
|
|||
PORT_SEVEN,
|
|||
PORT_EIGHT
|
|||
};
|
|||
class RedRelayLibrary
|
|||
{
|
|||
private:
|
|||
hid_device *dev;
|
|||
public:
|
|||
///
|
|||
/// \brief Primary class constructor
|
|||
///
|
|||
RedRelayLibrary(){};
|
|||
///
|
|||
/// \brief Connects to the relay
|
|||
/// \return Returns if the the operation succeded or not
|
|||
///
|
|||
bool ConnectRelay();
|
|||
///
|
|||
/// \brief Set a relay port state
|
|||
/// \param State of the relay
|
|||
/// \param Port to set the state
|
|||
///
|
|||
void SetRelayState(RelayState State, RelayPort Port);
|
|||
///
|
|||
/// \brief Gets the relay state
|
|||
/// \param Port to get the state
|
|||
/// \return
|
|||
///
|
|||
RelayState GetRelayState(RelayPort Port);
|
|||
///
|
|||
/// \brief Disconnects the relay and dispose it
|
|||
///
|
|||
void DisconnectRelay();
|
|||
};
|
|||
#endif // REDRELAYLIBRARY_H
|