Lugovtsov/project/hardware/Generator.hpp

60 lines
1.1 KiB
C++
Raw Normal View History

2022-11-01 16:18:53 +03:00
#pragma once
2022-11-28 18:31:51 +03:00
#include <string>
#include <iostream>
#include "Utils.hpp"
class Generator
2022-11-01 16:18:53 +03:00
{
public:
2022-11-28 18:31:51 +03:00
Generator();
void command(std::string const &comm) const;
std::string query(std::string const &comm) const;
2022-11-01 16:18:53 +03:00
2022-11-28 18:31:51 +03:00
void set_channel(channels ch)
2022-11-01 16:18:53 +03:00
{
2022-11-28 18:31:51 +03:00
m_channel = "C" + std::to_string(static_cast<ind_t>(ch));
2022-11-01 16:18:53 +03:00
}
void buzz()
{
command("BUZZ ON");
}
void set_waveform(std::string waveform)
{
command(m_channel + ":BSWV WVTP," + waveform);
}
void set_frequency(double frequency)
{
command(m_channel + ":BSWV FRQ," + std::to_string(frequency));
}
void set_period(double period)
{
command(m_channel + ":BSWV PERI," + std::to_string(period));
}
void set_amplitude(double amplitude)
{
command(m_channel + ":BSWV AMP," + std::to_string(amplitude));
}
void set_offset(double offset)
{
command(m_channel + ":BSWV OFST," + std::to_string(offset));
}
void set_phase(double phase)
{
command(m_channel + ":BSWV PHSE," + std::to_string(phase));
}
private:
2022-11-28 18:31:51 +03:00
std::string m_root_path;
2022-11-01 16:18:53 +03:00
std::string m_channel;
};