rework 3.5.1

This commit is contained in:
Глеб Луговцов 2022-11-10 15:26:32 +03:00
parent 49730eee05
commit 59cc284466
9 changed files with 98 additions and 10 deletions

BIN
3.5.1-ne-plasma/latex.zip Normal file

Binary file not shown.

Binary file not shown.

View File

@ -13,10 +13,10 @@ public:
return name;
}
protected:
void command(std::string comm);
std::string query(std::string comm);
protected:
std::string name;
std::string root_path;
};

View File

@ -0,0 +1,28 @@
#pragma once
#include <iostream>
#include <string>
#include "Oscilloscope.hpp"
class Measurement
{
public:
Measurement() = default;
Measurement(std::string name_) : name(name_) { }
Measurement(std::string stat_response, bool)
{
size_t name_start = stat_response.find(" C") + 5;
size_t name_end = stat_response.find(":");
name = stat_response.substr(name_start, name_end - name_start);
}
// private:
std::string name;
double mean;
double min;
double max;
double std_dev;
double count;
};

View File

@ -1,8 +1,61 @@
#pragma once
#include "Device.hpp"
#include "Measurement.hpp"
#include <string>
#include <unistd.h>
class Oscilloscope : public Device
{
public:
Oscilloscope(std::string path_name) : Device(path_name) {}
Oscilloscope(std::string path_name) : Device(path_name), m_channel("C1") {}
void set_channel(size_t channel)
{
if (channel == 1 || channel == 2)
m_channel = "C" + std::to_string(channel);
else
std::cerr << "Invalid channel" << std::endl;
}
Measurement get_pkpk()
{
comm_param_custom("PKPK");
comm_param_stat(1);
// size_t count = 0;
// while (count <= 20)
// {
// std::string response = quer_param_value("STAT1");
// size_t count_ind = response.find("count,") + 5;
// std::string count_str = response.substr(count_ind);
// std::cerr << count_str;
// comm_param_stat(0);
// count = std::stoi(count_str);
// }
std::string response = quer_param_value("STAT1");
comm_param_stat(0);
std::cout << response << std::endl;
return Measurement(response, 1);
}
private:
void comm_param_custom(std::string param)
{
command("PACU " + param + "," + m_channel);
}
void comm_param_stat(bool condition)
{
command("PASTAT " + condition ? "ON" : "OFF");
}
std::string quer_param_value(std::string custom)
{
return query("PAVA? " + custom);
}
std::string m_channel;
};

View File

@ -23,20 +23,14 @@ int main() {
return EXIT_FAILURE;
}
}
Generator generator(generator_path);
Oscilloscope oscilloscope(oscilloscope_path);
// work with devices
//generator.buzz();
std::string waveform;
std::cout << "Input waveform (SINE, SQUARE, RAMP, PULSE, NOISE, ARB, DC, PRBS, IQ):" << std::endl;
std::cin >> waveform;
generator.set_waveform(waveform);
std::cout << oscilloscope.query("C1:WF? DAT2").substr(1, 3) << std::endl;
return EXIT_SUCCESS;
}

13
project/hardware/osc.md Normal file
View File

@ -0,0 +1,13 @@
## Channel commands
TRA -- trace
VDIV -- vertical sensitivity
## MEASURE commands
PACU -- parameter custom
PAVA? -- parameter value
## WAVEFORM commands
#todo

Binary file not shown.