CableTestBench/Sources/IOModulesInterface.h
2019-05-13 11:49:37 -04:00

62 lines
1.3 KiB
C++

#ifndef IOMODULESINTERFACE_H
#define IOMODULESINTERFACE_H
#include "SeaMAX.h"
#include <QTimer>
#include <QObject>
#include <QBitArray>
#define IO_MODULES_REFRESH_INTERVAL 300 //ms
#define IO_COUNT 128 //4 modules of 32 bits
class CIOModulesInterface : public QObject
{
Q_OBJECT
public:
enum eModulesSlaveIDDefs
{
INPUTS_MODULE_1_SLAVE_ID = 1,
INPUTS_MODULE_2_SLAVE_ID = 2,
INPUTS_MODULE_3_SLAVE_ID = 3,
INPUTS_MODULE_4_SLAVE_ID = 4,
OUTPUTS_MODULE_1_SLAVE_ID = 5,
OUTPUTS_MODULE_2_SLAVE_ID = 6,
OUTPUTS_MODULE_3_SLAVE_ID = 7,
OUTPUTS_MODULE_4_SLAVE_ID = 8
};
CIOModulesInterface();
~CIOModulesInterface();
int OpenIOModules(QString IPAddress);
int CloseIOModules();
int SetOutputs(QBitArray Outputs);
QBitArray GetInputStates();
QBitArray GetOutputStates();
int ResetOutputs();
private:
SM_HANDLE hndl;
// QTimer *mIOModulesQueryTimer;
unsigned char mInputsBuffer[16];
unsigned char mOutputsBuffer[16];
unsigned char mOutputsStatebuffer[16];
int ReadInputModules();
int WriteOutputModules();
int ReadOutputStates();
int DoAllIOTransactions();
QBitArray CharBufferToBitArray(unsigned char *buf, int size_in_bytes);
public slots:
void IOModulesQueryTimerExpired();
};
#endif // IOMODULESINTERFACE_H