This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLockedInstance.hpp
62 lines (50 loc) · 2.1 KB
/
LockedInstance.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Created by Raini Wu, February 21st 2021
* Contact me at: [email protected]
*/
#ifndef LockedInstance_hpp
#define LockedInstance_hpp
#include <chrono>
#include <thread>
#include <uhd/usrp/multi_usrp.hpp>
#include "Timeable.hpp"
namespace locker {
enum class clockSources { internal = 0, external = 1, mimo = 2 };
static const char *sources[]{"internal", "external", "mimo"};
class LockedInstance {
public:
/**
* Creates a USRP instance with given parameters
*/
LockedInstance(const double &freq = 0.0, const double &lo_offset = 0.0,
const double &rxgain = 0.0, const double &txgain = 1.0,
const double &rxrate = 1e6, const double &txrate = 1e6,
const uhd::device_addr_t &anAddr = uhd::device_addr_t(""),
const clockSources &aSource = clockSources::internal,
const std::string &rxant = "TX/RX",
const std::string &txant = "TX/RX",
const double &setupTime = 1.0);
~LockedInstance();
/** checks all TX/RX channels for lo and sensor lock */
bool checkAllLock(const clockSources &aSource = clockSources::internal);
/** send a series of timed commands at given time in future with given
* interval in-between*/
void sendTimed(const std::vector<ITimeable *> &command, double time = 1.0,
double interval = 0.0);
/** send a series of timed commands with a list input time **/
void sendTimed(const std::vector<ITimeable *> &command,
const std::vector<double> &triggerTimes);
protected:
/** maps clockSources enum to string */
inline std::string getSource(const clockSources &aSource) {
return sources[static_cast<int>(aSource)];
}
/** sets freq, lo_lock, and others for all USRP TX and RX channels */
void tuneAll(const uhd::tune_request_t &aRequest, const double &rxgain,
const double &txgain, const double &rxrate, const double &txrate,
const std::string &rxant = "TX/RX",
const std::string &txant = "TX/RX");
uhd::usrp::multi_usrp::sptr myUSRP; /** USRP instance */
};
} // namespace locker
#endif