RTXI  2.4
The Real-Time eXperiment Interface Documentation
daq_tests.h
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  */
19 
20 #ifndef DAQ_TESTS_H
21 #define DAQ_TESTS_H
22 
23 #include <gtest/gtest.h>
24 #include <gmock/gmock.h>
25 #include <string>
26 #include <list>
27 #include <daq.h>
28 #include <io.h>
29 
30 #include <sstream>
31 
32 class MockDAQDriver : public DAQ::Driver
33 {
34 public:
35  MockDAQDriver(const std::string name) : DAQ::Driver(name) { }
37 
38  MOCK_METHOD(DAQ::Device *, createDevice, (const std::list<std::string>&), (override));
39 };
40 
41 class MockDAQDevice : public DAQ::Device
42 {
43 public:
44  MockDAQDevice(std::string a, IO::channel_t *b, size_t s) : DAQ::Device(a, b, s) { }
46 
47  MOCK_METHOD(size_t, getChannelCount, (DAQ::type_t), (const, override));
48  MOCK_METHOD(bool, getChannelActive, (DAQ::type_t,DAQ::index_t), (const, override));
49  MOCK_METHOD(int, setChannelActive, (DAQ::type_t,DAQ::index_t,bool), (override));
50  MOCK_METHOD(size_t, getAnalogRangeCount, (DAQ::type_t,DAQ::index_t), (const, override));
51  MOCK_METHOD(size_t, getAnalogReferenceCount, (DAQ::type_t,DAQ::index_t), (const, override));
52  MOCK_METHOD(size_t, getAnalogUnitsCount, (DAQ::type_t,DAQ::index_t), (const, override));
53  MOCK_METHOD(size_t, getAnalogDownsample, (DAQ::type_t,DAQ::index_t), (const, override));
54  MOCK_METHOD(std::string, getAnalogRangeString, (DAQ::type_t,DAQ::index_t,DAQ::index_t), (const, override));
55  MOCK_METHOD(std::string, getAnalogReferenceString, (DAQ::type_t,DAQ::index_t,DAQ::index_t), (const, override));
56  MOCK_METHOD(std::string, getAnalogUnitsString, (DAQ::type_t,DAQ::index_t,DAQ::index_t), (const, override));
57  MOCK_METHOD(double, getAnalogGain, (DAQ::type_t,DAQ::index_t), (const, override));
58  MOCK_METHOD(double, getAnalogZeroOffset, (DAQ::type_t,DAQ::index_t), (const, override));
63  MOCK_METHOD(int, setAnalogGain, (DAQ::type_t,DAQ::index_t,double), (override));
65  MOCK_METHOD(int, setAnalogZeroOffset, (DAQ::type_t,DAQ::index_t,double), (override));
69  MOCK_METHOD(int, setAnalogDownsample, (DAQ::type_t, DAQ::index_t, size_t), (override));
72  MOCK_METHOD(double, getAnalogCalibrationValue, (DAQ::type_t,DAQ::index_t), (const, override));
78 };
79 
80 class DAQManagerTest : public ::testing::Test
81 {
82 public:
83  static void callback(DAQ::Device *device, void *) { device->getChannelCount(DAQ::AI); }
84 
85 protected:
88 
90  std::stringstream cerr_buffer;
91  std::streambuf *cerr_original_buffer;
92 };
93 
94 #endif
MockDAQDriver
Definition: daq_tests.h:32
DAQ::Driver::createDevice
virtual Device * createDevice(const std::list< std::string > &args)=0
MockDAQDriver::~MockDAQDriver
~MockDAQDriver()
Definition: daq_tests.h:36
DAQ::Device::setAnalogOffsetUnits
virtual int setAnalogOffsetUnits(type_t type, index_t index, index_t units)=0
DAQ::type_t
type_t
Definition: daq.h:38
DAQ::Device::getChannelCount
virtual size_t getChannelCount(type_t type) const =0
DAQManagerTest::callback
static void callback(DAQ::Device *device, void *)
Definition: daq_tests.h:83
DAQ::Device::getAnalogDownsample
virtual size_t getAnalogDownsample(type_t type, index_t index) const =0
DAQ::Device::getAnalogUnits
virtual index_t getAnalogUnits(type_t type, index_t index) const =0
DAQ::Device::setAnalogCounter
virtual int setAnalogCounter(type_t type, index_t index)=0
DAQManagerTest::~DAQManagerTest
~DAQManagerTest()
Definition: daq_tests.cpp:32
DAQManagerTest::cerr_buffer
std::stringstream cerr_buffer
Definition: daq_tests.h:90
DAQ::index_t
unsigned long index_t
Definition: daq.h:49
DAQ::Device::getAnalogGain
virtual double getAnalogGain(type_t type, index_t index) const =0
MockDAQDevice::MockDAQDevice
MockDAQDevice(std::string a, IO::channel_t *b, size_t s)
Definition: daq_tests.h:44
DAQ::Device::setAnalogZeroOffset
virtual int setAnalogZeroOffset(type_t type, index_t index, double offset)=0
DAQ::Device::setAnalogCalibrationValue
virtual int setAnalogCalibrationValue(type_t type, index_t index, double value)=0
MockDAQDriver::MOCK_METHOD
MOCK_METHOD(DAQ::Device *, createDevice,(const std::list< std::string > &),(override))
DAQ::Device::getAnalogRange
virtual index_t getAnalogRange(type_t type, index_t index) const =0
DAQ::Device::setAnalogUnits
virtual int setAnalogUnits(type_t type, index_t index, index_t units)=0
DAQ::Device::getAnalogCalibrationValue
virtual double getAnalogCalibrationValue(type_t type, index_t index) const =0
DAQ
DAQ Oriented Classes.
Definition: daq.h:32
DAQ::Device::setChannelActive
virtual int setChannelActive(type_t type, index_t index, bool state)=0
daq.h
DAQ::Device::getChannelActive
virtual bool getChannelActive(type_t type, index_t index) const =0
DAQ::Device::getAnalogRangeCount
virtual size_t getAnalogRangeCount(type_t type, index_t index) const =0
DAQ::Device::getAnalogUnitsCount
virtual size_t getAnalogUnitsCount(type_t type, index_t index) const =0
MockDAQDriver::MockDAQDriver
MockDAQDriver(const std::string name)
Definition: daq_tests.h:35
DAQ::Device::setAnalogCalibrationActive
virtual int setAnalogCalibrationActive(type_t type, index_t index, bool state)=0
IO::channel_t
Definition: io.h:56
DAQ::Device::getAnalogZeroOffset
virtual double getAnalogZeroOffset(type_t type, index_t index) const =0
DAQ::direction_t
direction_t
Definition: daq.h:57
DAQManagerTest::DAQManagerTest
DAQManagerTest()
Definition: daq_tests.cpp:25
MockDAQDevice::~MockDAQDevice
~MockDAQDevice()
Definition: daq_tests.h:45
RT::Device::Device
Device(void)
Definition: rt.cpp:119
DAQ::Device::getAnalogReference
virtual index_t getAnalogReference(type_t type, index_t index) const =0
DAQ::Manager
Definition: daq.h:73
DAQManagerTest::daq_manager
DAQ::Manager * daq_manager
Definition: daq_tests.h:89
DAQ::Device::getAnalogRangeString
virtual std::string getAnalogRangeString(type_t type, index_t index, index_t range) const =0
DAQ::Device::getDigitalDirection
virtual direction_t getDigitalDirection(index_t index) const =0
DAQ::Device::getAnalogCalibrationState
virtual bool getAnalogCalibrationState(type_t type, index_t index) const =0
DAQ::Device::getAnalogReferenceCount
virtual size_t getAnalogReferenceCount(type_t type, index_t index) const =0
MockDAQDevice::MOCK_METHOD
MOCK_METHOD(size_t, getChannelCount,(DAQ::type_t),(const, override))
DAQ::Device::getAnalogReferenceString
virtual std::string getAnalogReferenceString(type_t type, index_t index, index_t reference) const =0
io.h
DAQ::Device::setAnalogRange
virtual int setAnalogRange(type_t type, index_t index, index_t range)=0
DAQ::Device::setDigitalDirection
virtual int setDigitalDirection(index_t index, direction_t direction)=0
MockDAQDevice
Definition: daq_tests.h:41
DAQManagerTest::cerr_original_buffer
std::streambuf * cerr_original_buffer
Definition: daq_tests.h:91
DAQ::Device::getAnalogCalibrationActive
virtual bool getAnalogCalibrationActive(type_t type, index_t index) const =0
DAQ::Device::setAnalogReference
virtual int setAnalogReference(type_t type, index_t index, index_t reference)=0
DAQ::Device::getAnalogUnitsString
virtual std::string getAnalogUnitsString(type_t type, index_t index, index_t units) const =0
DAQ::Device::setAnalogGain
virtual int setAnalogGain(type_t type, index_t index, double gain)=0
DAQ::AI
@ AI
Definition: daq.h:40
DAQ::Driver::Driver
Driver(const std::string &name)
Definition: daq.cpp:33
DAQManagerTest
Definition: daq_tests.h:80
DAQ::Device::setAnalogDownsample
virtual int setAnalogDownsample(type_t type, index_t index, size_t downsample)=0
DAQ::Device
Definition: daq.h:139
DAQ::Device::getAnalogOffsetUnits
virtual index_t getAnalogOffsetUnits(type_t type, index_t index) const =0
DAQ::Driver
Definition: daq.h:397