Вот пошаговый список с изображениями и кодом, подробно описывающим то, что я сделал:
- Я установил входной канал в качестве сигнала времени. (Dewesoft требуется как минимум один входной канал).

- Я установил два выходных канала для цифрового выхода 1 и 2 соответственно. Затем я подключил осциллограф к своим цифровым выходным контактам и подключил источник 5 В как к входному, так и к выходному контакту, который зарезервирован для 5 В, просто чтобы охватить все мои базы.

- Я связал свои цифровые выходные контакты с программным обеспечением выходные данные.

- Я написал свой код в рамках скелетного кода, который предлагает Dewesoft:
class Module : public bsc::MathModule {
public:
Module();
~Module();
void configure() override;
void start() override;
void stop() override;
void clear() override;
// MY CODE BELOW THIS POINT
// Outputs have been mapped to Ctrl DO1 / Ctrl DO2 in A/D out
double PyroOneOut = 0.0; // "First Pyro's Output"
double PyroTwoOut = 0.0; // "Second Pyro's Out"
private:
// Timing parameters (ms)
const double t1_ms = 25.0; // DO1 fires at 25 ms
const double t2_ms = 50.0; // DO2 fires at 50 ms
const double width_ms = 5.0; // pulse width (will change if needed)
// Internal clock
std::chrono::steady_clock::time_point t0;
};
inline Module::Module() {
// Procedure which gets called the first thing a setup containing your module gets loaded
// or when the window with your module's setup form is closed.
// During this call only variables in 'published' struct are properly set.
// Useful for loading heavy libraries, reading from files, etc.
}
inline Module::~Module() {
// Called when your module is no longer used, giving you an opportunity to clean up.
}
inline void Module::configure() {
// Procedure used for overriding settings set in 'Configure' tab.
// Most useful for setting blockSizeInSamples, and output channel's units, axes, and
// expectedAsyncRates, based on the values of published variables.
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::start() {
// Procedure which gets called at the start of a new measurement,
// strictly after Module::init(). Useful for setting initial values.
// Called at measurement start — zero outputs and arm the timer.
t0 = std::chrono::steady_clock::now();
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::stop() {
// A converse of Module::start(), called when the measurement is stopped.
// Ensure outputs go LOW when stopping.
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::clear() {
// Procedure which gets called whenever DEWESoft clears data in channels,
// e.g., when storing is started.
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::calculate() {
// Procedure which gets called repeatedly whenever DEWESoft has exactly
// 'Block size' (or 1, in sample-based mode) number of new samples in input channels.
using namespace std::chrono;
const double ms =
duration(steady_clock::now() - t0).count();
const bool do1_high = (ms >= t1_ms) && (ms < (t1_ms + width_ms));
const bool do2_high = (ms >= t2_ms) && (ms < (t2_ms + width_ms));
PyroOneOut = do1_high ? 1.0 : 0.0;
PyroTwoOut = do2_high ? 1.0 : 0.0;
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... s-c-module
Мобильная версия