7#include <neoapi/neoapi.hpp>
10#include <tabulate/table.hpp>
18 static std::random_device rd;
19 static std::mt19937 gen(rd());
20 std::uniform_int_distribution<> dis(0, 15);
21 std::uniform_int_distribution<> dis2(8, 11);
26 for(
int i = 0; i < 8; i++) {
30 for(
int i = 0; i < 4; i++) {
34 for(
int i = 0; i < 3; i++) {
39 for(
int i = 0; i < 3; i++) {
43 for(
int i = 0; i < 12; i++) {
49std::vector<std::string>
50split(
const std::string& s,
char delimiter)
52 std::vector<std::string> tokens;
57 tokens.push_back(token);
65 tokens.push_back(token);
71strip(
const std::string& s,
const std::string& delimiters)
74 size_t end = s.size();
75 IRSOL_LOG_TRACE(
"Stripping delimiters '{0:s}' from string '{1:s}'", delimiters, s);
76 while((start < end) && (delimiters.find(s[start]) != std::string::npos)) {
79 while((start < end) && (delimiters.find(s[end - 1]) != std::string::npos)) {
83 auto result = s.substr(start, end - start);
89stripString(
const std::string& s,
const std::string& strippedString)
93 IRSOL_LOG_TRACE(
"Stripping string '{0:s}' from string '{1:s}'", strippedString, s);
95 if(
result.find(strippedString) == 0) {
100 if(
result.rfind(strippedString) ==
result.size() - strippedString.size()) {
105 "Stripped string '{0:s}' from string '{1:s}' is '{2:s}'", s, strippedString,
result);
113 using system_clock_t = std::chrono::system_clock;
114 auto now_sys = std::chrono::time_point_cast<system_clock_t::duration>(
115 tp - irsol::types::clock_t::now() + system_clock_t::now());
118 auto us = std::chrono::duration_cast<std::chrono::microseconds>(now_sys.time_since_epoch()) %
119 std::chrono::seconds(1);
122 std::time_t t_c = system_clock_t::to_time_t(now_sys);
123 std::tm tm = *std::localtime(&t_c);
125 std::stringstream ss;
126 ss << std::put_time(&tm,
"%F %T");
127 ss <<
'.' << std::setfill(
'0') << std::setw(6) << us.count();
135 std::stringstream ss;
136 if(dr.count() == 0) {
140 if(dr >= std::chrono::hours(1)) {
141 auto hours = std::chrono::duration_cast<std::chrono::hours>(dr);
142 ss << std::to_string(hours.count());
146 if(dr >= std::chrono::minutes(1)) {
147 auto minutes = std::chrono::duration_cast<std::chrono::minutes>(dr);
148 ss << std::setw(2) << std::setfill(
'0') << std::to_string(minutes.count());
152 if(dr >= std::chrono::seconds(1)) {
153 auto seconds = std::chrono::duration_cast<std::chrono::seconds>(dr);
154 ss << std::setw(2) << std::setfill(
'0') << std::to_string(seconds.count());
158 if(dr >= std::chrono::milliseconds(1)) {
159 auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(dr);
160 ss << std::setw(3) << std::setfill(
'0') << std::to_string(milliseconds.count());
164 if(dr >= std::chrono::microseconds(1)) {
165 auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(dr);
166 ss << std::setw(3) << std::setfill(
'0') << std::to_string(microseconds.count());
170 if(dr >= std::chrono::nanoseconds(1)) {
171 auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(dr);
172 ss << std::setw(3) << std::setfill(
'0') << std::to_string(nanoseconds.count());
181std::vector<irsol::types::byte_t>
185 return {data, data + s.size()};
191 const auto* data =
reinterpret_cast<const char*
>(
input.data());
192 return std::string(data, data +
input.size());
199 NeoAPI::Cam cam = NeoAPI::Cam();
202 IRSOL_LOG_TRACE(
"Trying to connect to default camera with SN '{0:s}'.", cameraSerialNumber);
204 cam.Connect(cameraSerialNumber);
205 }
catch(NeoAPI::NotConnectedException& e) {
219 NeoAPI::CamInfoList& infoList = NeoAPI::CamInfoList::Get();
229 return "700011810487";
Assertion macros and utilities based on the PPK_ASSERT library.
#define IRSOL_ASSERT_FATAL
Fatal-level assertion macro.
#define IRSOL_LOG_DEBUG(...)
Logs a debug-level message using the default logger.
#define IRSOL_LOG_TRACE(...)
Logs a trace-level message using the default logger.
Logging utilities and configuration for the irsol library.
clock_t::duration duration_t
Alias for a duration of time as defined by clock_t.
std::byte byte_t
Alias for a single byte used in serialization or binary data handling.
clock_t::time_point timepoint_t
Alias for a point in time as defined by clock_t.
constexpr const char * defaultCameraSerialNumber()
Default serial number for selecting the system camera.
NeoAPI::Cam loadDefaultCamera()
Loads the default camera device.
std::string bytesToString(const std::vector< irsol::types::byte_t > &input)
Converts a std::vector of irsol::types::byte_t to a std::string.
std::string strip(const std::string &s, const std::string &delimiters=" \t\r\n")
Removes leading and trailing characters from a string.
NeoAPI::CamInfoList & discoverCameras()
Discovers all cameras connected to the system.
std::string stripString(const std::string &s, const std::string &strippedString)
Removes all occurrences of a specific substring from the start and end of a string.
std::string uuid()
Generates a new UUID string.
std::vector< std::string > split(const std::string &s, char delimiter)
Splits a string into tokens based on a delimiter.
std::vector< irsol::types::byte_t > stringToBytes(const std::string &s)
Converts a std::string to a std::vector of irsol::types::byte_t.
std::string timestampToString(irsol::types::timepoint_t tp)
Converts a steady_clock time point to a human-readable string.
std::string durationToString(irsol::types::duration_t dr)
Converts a duration to a human-readable string.
General utility functions used throughout the irsol library.