fbgsense 0.1
Generic FBG spectrum analysis tool
interrogator.h
1/*
2 * This file is a part of the project "fbgsense", which is released under MIT license.
3 * Copyright (c) 2022 Daniel Múčka, Masaryk University, Faculty of Informatics
4 * See file LICENSE or visit https://opensource.org/licenses/MIT for full license details.
5 */
6
7#pragma once
8
9#include <string>
10#include <chrono>
11#include <mutex>
12
13#include <sockpp/tcp_connector.h>
14#include <fftw3.h>
15
16#include "spectrum/spectrum_sm125.h"
17
18enum class interrogator_t
19{
20 sm125,
21 hyperion
22};
23
24constexpr std::string convert_legacy_channel(uint8_t channel)
25{
26 switch (channel)
27 {
28 case 1: return "1.1";
29 case 2: return "2.1";
30 case 3: return "3.1";
31 case 4: return "4.1";
32
33 case 5: return "1.2";
34 case 6: return "2.2";
35 case 7: return "3.2";
36 case 8: return "4.2";
37
38 case 9: return "1.3";
39 case 10: return "2.3";
40 case 11: return "3.3";
41 case 12: return "4.3";
42
43 case 13: return "1.4";
44 case 14: return "2.4";
45 case 15: return "3.4";
46 case 16: return "4.4";
47 }
48
49 throw std::exception("Invalid channel value.");
50}
51
56{
57 sockpp::socket_initializer m_sockinit; // needed for proper init and cleanup of socket objects
58 sockpp::tcp_connector* m_conn;
59 std::mutex m_socket_mutex;
60 std::string m_address;
61 uint16_t m_port;
62
63 std::string m_serial_number;
64 std::string m_idn;
65 std::string m_system_image_id;
66 std::string m_num_daq_duts;
67 std::string m_scan_speed;
68 std::string m_min_wvl;
69 std::string m_max_wvl;
70
71 spectrum_sm125 m_spectrums;
72
73 void recv_min_max_wvl();
74 void recv_scan_speed();
75 void recv_num_daq_duts();
76 void recv_serial_number();
77 void recv_system_image_id();
78
79 std::string parse_str_reply(std::string reply);
80public:
81 interrogator(std::string address, uint16_t port);
82 interrogator(interrogator&& other) noexcept;
84
85 bool ping();
86 void recv_spectrums();
87 std::unique_ptr<uint8_t[]> recv_spectrums_data(size_t& dataLength);
88 void set_channels(uint8_t count);
89
90 std::string min_wvl();
91 std::string max_wvl();
92 std::string scan_speed();
93 std::string num_daq_duts();
94 std::string system_image_id();
95 std::string idn();
96 std::string serial_number();
97
98 spectrum_sm125* spectrums();
99
100 std::unique_ptr<uint8_t[]> send_command(std::string cmd);
101 std::unique_ptr<uint8_t[]> send_command(std::string cmd, size_t& replyLength);
102};
Data structure providing high-level access to the interrogator device.
Definition: interrogator.h:56
Spectrum of SM125 interrogator.
Definition: spectrum_sm125.h:44