2022-11-01 16:18:53 +03:00
|
|
|
#pragma once
|
2022-11-28 18:31:51 +03:00
|
|
|
#include <iostream>
|
2022-11-10 15:26:32 +03:00
|
|
|
#include <string>
|
2022-11-28 18:31:51 +03:00
|
|
|
#include <exception>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <stdlib.h>
|
2022-11-10 15:26:32 +03:00
|
|
|
#include <unistd.h>
|
2022-11-28 18:31:51 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "Utils.hpp"
|
2022-11-01 16:18:53 +03:00
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
class Oscilloscope
|
2022-11-01 16:18:53 +03:00
|
|
|
{
|
|
|
|
public:
|
2022-11-28 18:31:51 +03:00
|
|
|
Oscilloscope(std::string server_ip = "10.11.13.220", port_t server_port = 5024);
|
2022-11-10 15:26:32 +03:00
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
size_t command(std::string const &comm)
|
2022-11-10 15:26:32 +03:00
|
|
|
{
|
2022-11-28 18:31:51 +03:00
|
|
|
return send(m_client_side, comm.c_str(), comm.length(), 0);
|
2022-11-10 15:26:32 +03:00
|
|
|
}
|
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
std::string request();
|
|
|
|
size_t request(char *buf, size_t msg_size);
|
|
|
|
std::string query(std::string const& comm);
|
|
|
|
|
|
|
|
void set_channel(channels ch)
|
2022-11-10 15:26:32 +03:00
|
|
|
{
|
2022-11-28 18:31:51 +03:00
|
|
|
m_channel = "C" + std::to_string(static_cast<ind_t>(ch));
|
2022-11-10 15:26:32 +03:00
|
|
|
}
|
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
double parser(std::string const& comm, std::string const& to_find, std::string const& units);
|
2022-11-10 15:26:32 +03:00
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
double get_vdiv()
|
|
|
|
{
|
|
|
|
return parser(m_channel + ":VDIV?", "VDIV", "V");
|
|
|
|
}
|
|
|
|
|
|
|
|
double get_voffset()
|
2022-11-10 15:26:32 +03:00
|
|
|
{
|
2022-11-28 18:31:51 +03:00
|
|
|
return parser(m_channel + ":OFST?", "OFST", "V");
|
2022-11-10 15:26:32 +03:00
|
|
|
}
|
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
double get_timebase()
|
2022-11-10 15:26:32 +03:00
|
|
|
{
|
2022-11-28 18:31:51 +03:00
|
|
|
return parser("TDIV?", "TDIV", "S");
|
2022-11-10 15:26:32 +03:00
|
|
|
}
|
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
double get_sampling_rate()
|
2022-11-10 15:26:32 +03:00
|
|
|
{
|
2022-11-28 18:31:51 +03:00
|
|
|
return parser("SARA?", "SARA", "Sa/s");
|
2022-11-10 15:26:32 +03:00
|
|
|
}
|
|
|
|
|
2022-11-28 18:31:51 +03:00
|
|
|
void save_waveform(std::string file_name = "waveform.csv");
|
|
|
|
|
|
|
|
~Oscilloscope();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_client_side;
|
2022-11-10 15:26:32 +03:00
|
|
|
std::string m_channel;
|
2022-11-01 16:18:53 +03:00
|
|
|
};
|