Skip to content

Commit

Permalink
Merge pull request #175 from RTXI/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
fusge authored Oct 22, 2024
2 parents 4ea07d0 + 038fb46 commit 4e2670c
Show file tree
Hide file tree
Showing 51 changed files with 2,004 additions and 658 deletions.
23 changes: 7 additions & 16 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
---
# Enable ALL the things! Except not really
# misc-non-private-member-variables-in-classes: the options don't do anything
# Enable relevant things!
# cpp core guidelines is our main check that we try to follow as close as possible.
# The following are disabled checks because they don't make any sesne for our
# project:
# readability-identifier-naming: Should be enabled after main refactoring is done
# *-vararg: we are dealing with variable argument c functions. cannot be helped
# -modernize-deprecated-headers: dealing with c headers
# -modernize-use-nodiscard: We are dealing with legacy code so this is too much.
# -modernize-use-using: Conflicts with another warning.
# -hicpp-signed-bitwise: There are c functions that will fire this warning. bye bye.
# -cppcoreguidelines-owning-memory: Qt uses parent widget relationships.
# -readability-identifier-nanme: shorter names can make sense in some cases.
# -cppcoreguidelines-avoid-magic-numbers: Qt design is littered with these unfortunately.
# -readability-magic-numbers: Same reason as above - cannot be helped due to Qt
# -readability-redundant-access-specifiers: Qt's slot specifier produces this warning
# -abseil-string-find-str-contains: we don't use abseil strings in this project
Checks: "*,\
-abseil-string-find-str-contains,\
Checks: "bugprone-*, concurrency-*, cppcoreguidelines-*,\
modernize-*, performance-*, readability-*,\
-readability-redundant-access-specifiers,\
-readability-magic-numbers,\
-cppcoreguidelines-avoid-magic-numbers,\
-readability-identifier-length,\
-cppcoreguidelines-owning-memory,\
-hicpp-signed-bitwise,\
-hicpp-deprecated-headers,\
-*-vararg,\
-modernize-deprecated-headers,\
-modernize-use-trailing-return-type,\
-modernize-use-nodiscard,\
-modernize-use-using,\
-google-readability-todo,\
-readability-identifier-naming,\
-altera-*,\
-fuchsia-*,\
fuchsia-multiple-inheritance,\
-llvm-header-guard,\
-llvm-include-order,\
-llvmlibc-*,\
-misc-non-private-member-variables-in-classes"
-readability-identifier-naming"
WarningsAsErrors: ''
CheckOptions:
- key: 'bugprone-argument-comment.StrictMode'
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ find_package(Threads REQUIRED)
find_package(GSL REQUIRED)
#Some libraries are harder to find as package, so this solves that
find_library(nidaqmx NAMES libnidaqmx.so)
find_library(16aio168_api NAMES lib16aio168_api.so)

#Handle QT and boost libraries shenanigans
set(CMAKE_AUTOMOC ON)
Expand Down
8 changes: 8 additions & 0 deletions cmake/install-rules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ install(
)
endif()

if(16aio168_api)
install(
TARGETS rtxi_gsc16aio168_driver
DESTINATION ${CMAKE_INSTALL_BINDIR}
EXPORT rtxiLibraryTargets
)
endif()

install(
FILES
src/debug.hpp src/event.hpp src/io.hpp src/rt.hpp
Expand Down
2 changes: 1 addition & 1 deletion docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PROJECT_BRIEF = "The Real-Time eXperiment Interface Reference Manual"
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.

PROJECT_LOGO = "res/icons/RTXI-icon.svg"
PROJECT_LOGO = "@PROJECT_SOURCE_DIR@/res/icons/RTXI-icon.svg"

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DOXYFILE = 'Doxyfile'

LINKS_NAVBAR1 = [
(None, 'pages', [(None, 'about')]),
(None, 'pages', []),
(None, 'namespaces', []),
]

78 changes: 27 additions & 51 deletions libs/gen/gen_biphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,68 +16,44 @@
*/

#include "gen_biphase.h"

// default constructor
#include <cmath>

GeneratorBiphase::GeneratorBiphase()
: width(1)
, amplitude(1)
, delay(1)
: m_width(1)
, m_amplitude(1)
, m_delay(1)
{
dt = 1e-3;
numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
wave.clear();
for (int i = 0; i < floor(delay / dt); i++) {
wave.push_back(0); // initial delay
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(amplitude); // positive part
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(-amplitude); // negative part
}
numsamples = wave.size();
index = 0;
setDeltaTime(1e-3);
}

GeneratorBiphase::GeneratorBiphase(double delay, double width, double amplitude,
GeneratorBiphase::GeneratorBiphase(double delay,
double width,
double amplitude,
double dt)
: Generator()
: m_width(width)
, m_amplitude(amplitude)
, m_delay(delay)
{
numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
wave.clear();
for (int i = 0; i < floor(delay / dt); i++) {
wave.push_back(0); // initial delay
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(amplitude); // positive part
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(-amplitude); // negative part
}
numsamples = wave.size();
index = 0;
setDeltaTime(dt);
}

GeneratorBiphase::~GeneratorBiphase()
void GeneratorBiphase::init(double delay,
double width,
double amplitude,
double dt)
{
m_delay = delay;
m_width = width;
m_amplitude = amplitude;
setDeltaTime(dt);
setIndex(0);
}

void
GeneratorBiphase::init(double delay, double width, double amplitude, double dt)
double GeneratorBiphase::get()
{
numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
wave.clear();

for (int i = 0; i < floor(delay / dt); i++) {
wave.push_back(0); // initial delay
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(amplitude); // positive part
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(-amplitude); // negative part
}
numsamples = wave.size();
index = 0;
const double time = getIndex() * getDeltaTime() - m_delay;
getIndex()++;
if(time < 0.0) { return 0.0; }
const int sign = std::fmod(time,m_width) < m_width/2 ? 1 : -1;
return m_amplitude * sign;
}
11 changes: 6 additions & 5 deletions libs/gen/gen_biphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ class GeneratorBiphase : public Generator
// default constructor
GeneratorBiphase();
GeneratorBiphase(double delay, double width, double amplitude, double dt);
~GeneratorBiphase();

// initialize waveform
void init(double delay, double width, double amplitude, double dt);

protected:
double width; // s
double amplitude;
double delay; // s
double get() override;

private:
double m_width; // s
double m_amplitude;
double m_delay; // s
};

#endif /* GEN_BIPHASE_H_ */
69 changes: 28 additions & 41 deletions libs/gen/gen_mono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,46 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "gen_mono.h"
#include <cmath>

// default constructor
#include "gen_mono.h"

GeneratorMono::GeneratorMono()
: delay(1)
, width(1)
, amplitude(1)
: m_delay(1)
, m_width(1)
, m_amplitude(1)
{
dt = 1e-3;
numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
wave.clear();
for (int i = 0; i < floor(delay / dt); i++) {
wave.push_back(0); // initial delay
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(amplitude); // positive part
}
numsamples = wave.size();
index = 0;
setDeltaTime(1e-3);
}

GeneratorMono::GeneratorMono(double delay, double width, double amplitude,
GeneratorMono::GeneratorMono(double delay,
double width,
double amplitude,
double dt)
: Generator()
: m_delay(delay)
, m_width(width)
, m_amplitude(amplitude)

{
numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
wave.clear();
for (int i = 0; i < floor(delay / dt); i++) {
wave.push_back(0); // initial delay
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(amplitude); // positive part
}
numsamples = wave.size();
index = 0;
setDeltaTime(dt);
}

GeneratorMono::~GeneratorMono()
void GeneratorMono::init(double delay,
double width,
double amplitude,
double dt)
{
m_delay = delay;
m_width = width;
m_amplitude = amplitude;
setDeltaTime(dt);
setIndex(0);
}

void
GeneratorMono::init(double delay, double width, double amplitude, double dt)
double GeneratorMono::get()
{
numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
wave.clear();
for (int i = 0; i < floor(delay / dt); i++) {
wave.push_back(0); // initial delay
}
for (int i = 0; i < floor(width / dt); i++) {
wave.push_back(amplitude); // positive part
}
numsamples = wave.size();
index = 0;
const double time = getIndex() * getDeltaTime();
getIndex()++;
return m_amplitude
* static_cast<int>(std::fmod(time, m_width + m_delay) > m_delay);
}
11 changes: 6 additions & 5 deletions libs/gen/gen_mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ class GeneratorMono : public Generator
// default constructor
GeneratorMono();
GeneratorMono(double delay, double width, double amplitude, double dt);
~GeneratorMono();

// initialize waveform
void init(double delay, double width, double amplitude, double dt);

protected:
double delay; // s
double width; // s
double amplitude;
double get() override;

private:
double m_delay; // s
double m_width; // s
double m_amplitude;
};

#endif /* GEN_MONO_H_ */
Loading

0 comments on commit 4e2670c

Please sign in to comment.