test_sdk/hw/test_hw/main.cpp

83 lines
3.6 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <QCoreApplication>
#include <QObject>
#include <iostream>
#include "hw/gtl_hw.h"
#include "hw/gtl_hw_device.h"
#include "hw/gtl_hw_generator.h"
//#include "math/gtl_math_sum.h"
//#include "math/gtl_math_rms.h"
//#include "math/gtl_math_spec.h"
//#include "math/gtl_math_delta_phase_spec.h"
#include "math/gtl_math_max.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
//создаем объект hardware. параметр - путь к папке с плагинами.
gtl::hw::hw hw("../../.output/.hwplugins/debug");
//получаем список доступных устройств.
QStringList devices = hw.devices();
qDebug() << devices;
//создаем устройство. параметр имя устройства.
//gtl::hw::device* d = hw.create_device("ni");
gtl::hw::device* d = new gtl::hw::generator();
if(d == NULL)
{
qDebug() << "error creating device";
}
else
{
// gtl::math::sum *sum;
// gtl::math::rms *rms;
// gtl::math::spec *spec;
// gtl::math::delta_phase_spec *delta_phase_spec;
gtl::math::max *max;
//задаем параметры каналов.
// d->ai(0)->set_iepe(true);
// d->ai(0)->set_sensitivity(0.001);
gtl::hw::generator_analog_input* input = static_cast<gtl::hw::generator_analog_input*>(d->ai(0));
// input->set_phase(87);
input->set_freq(100);
input->set_ampl(5);
// input = static_cast<gtl::hw::generator_analog_input*>(d->ai(1));
// input->set_freq(100);
// input = static_cast<gtl::hw::generator_analog_input*>(d->ai(1));
//запускаем устройство. первый параметр - id, второй - частота дискретизации
qDebug() << d->start("Dev1", 51200);
//в библиотеке будет класс объектов, предназначеных для вычисления скалярных величин, характеризующих сигнал. скз, частота и т.п.
//это объект, вычисляющий сумму поступающих аналоговых данных. для примера.
//параметр - канал аналоговых данных. в данном случае входной канал устройства.
// sum = new gtl::math::sum(d->ai(3));
// rms = new gtl::math::rms(d->ai(3));
// spec = new gtl::math::spec(gtl::math::spec::types::phase, d->ai(3));
// delta_phase_spec = new gtl::math::delta_phase_spec(d->ai(0), d->ai(1));
// delta_phase_spec->set_frequency(100);
// delta_phase_spec->set_resolution(10);
max = new gtl::math::max(d->ai(0));
// spec->set_frequency(2560);
//слот получения новых данных.
// QObject::connect(d, &gtl::hw::device::received_data, [=](){qDebug() << "data recieved sum:\t" << sum->value();});
// QObject::connect(d, &gtl::hw::device::received_data, [=](){qDebug() << "data recieved rms:\t" << rms->value();});
// QObject::connect(spec, &gtl::math::spec::max_harm_idx, [=](int val){qDebug() << "idx spec:\t" << val;});
// QObject::connect(delta_phase_spec, &gtl::math::delta_phase_spec::value_changed, [=](){qDebug() << "delta phase:\t" << delta_phase_spec->value();});
QObject::connect(d, &gtl::hw::device::received_data, [=](){qDebug() << "data recieved max:\t" << max->value();});
}
return a.exec();
}