...
This commit is contained in:
parent
1806ffda99
commit
1dacab88fe
@ -424,7 +424,8 @@ size_t RaptorEagleCCD::clReadAndCheckAck(byte_seq_t& bytes)
|
||||
if (_clCommandAckBit && nbytes) {
|
||||
auto ack = *(bytes.end() - 1 - _clChecksumBit);
|
||||
if (ack != CL_ETX) {
|
||||
throw std::error_code(ack, RaptorEagleControllerErrorCategory::get());
|
||||
// throw std::system_error(std::error_code(ack, RaptorEagleControllerErrorCategory::get()));
|
||||
throw std::system_error(ack, RaptorEagleControllerErrorCategory::get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -481,7 +482,7 @@ size_t RaptorEagleCCD::clWrite(const byte_seq_t& bytes)
|
||||
std::format("pxd_serialWrite({}, 0, {}, {})", _cameraUnitmap, (void*)bytes.data(), bytes.size()));
|
||||
|
||||
if (nbytes != bytes.size()) {
|
||||
throw std::error_code(RaptorEagleCCDError::ERROR_CAMLINK_WRITE);
|
||||
throw std::system_error(RaptorEagleCCDError::ERROR_CAMLINK_WRITE);
|
||||
}
|
||||
|
||||
// send trailing ETX and possible checksum bytes
|
||||
@ -496,7 +497,7 @@ size_t RaptorEagleCCD::clWrite(const byte_seq_t& bytes)
|
||||
n = pxd_serialWrite(_cameraUnitmap, 0, (char*)etx_checksum_bytes, tr_nbytes),
|
||||
std::format("pxd_serialWrite({}, 0, {}, {})", _cameraUnitmap, (void*)etx_checksum_bytes, tr_nbytes));
|
||||
if (n != tr_nbytes) {
|
||||
throw std::error_code(RaptorEagleCCDError::ERROR_CAMLINK_WRITE);
|
||||
throw std::system_error(RaptorEagleCCDError::ERROR_CAMLINK_WRITE);
|
||||
}
|
||||
|
||||
nbytes += n;
|
||||
@ -756,7 +757,7 @@ void RaptorEagleCCD::startAquisition()
|
||||
// if (_isAcqInProgress) {
|
||||
if (AcquisitionProcess::isAcqInProgress) {
|
||||
logError("Acquisition is in progress! Exit!");
|
||||
throw std::error_code(RaptorEagleCCDError::ERROR_ACQUISITION_IN_PROGRESS);
|
||||
throw std::system_error(RaptorEagleCCDError::ERROR_ACQUISITION_IN_PROGRESS);
|
||||
}
|
||||
|
||||
auto bytes = readRegisters({0xD4}); // trigger mode register
|
||||
@ -764,7 +765,7 @@ void RaptorEagleCCD::startAquisition()
|
||||
|
||||
if (bits.test(CL_TRIGGER_MODE_EXT_TRIGGER_BIT)) {
|
||||
logError("External trigger mode is set! Nothing to do, exit!");
|
||||
throw std::error_code(RaptorEagleCCDError::ERROR_EXT_TRIGGER_MODE);
|
||||
throw std::system_error(RaptorEagleCCDError::ERROR_EXT_TRIGGER_MODE);
|
||||
}
|
||||
|
||||
|
||||
@ -963,7 +964,7 @@ void RaptorEagleCCD::initAttrComm()
|
||||
if (resetMicro())
|
||||
return;
|
||||
|
||||
throw std::error_code(RaptorEagleCCDError::ERROR_CANNOT_RESET_MICRO);
|
||||
throw std::system_error(RaptorEagleCCDError::ERROR_CANNOT_RESET_MICRO);
|
||||
});
|
||||
|
||||
|
||||
@ -972,7 +973,7 @@ void RaptorEagleCCD::initAttrComm()
|
||||
if (resetFPGA())
|
||||
return;
|
||||
|
||||
throw std::error_code(RaptorEagleCCDError::ERROR_CANNOT_RESET_FPGA);
|
||||
throw std::system_error(RaptorEagleCCDError::ERROR_CANNOT_RESET_FPGA);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -335,7 +335,7 @@ private:
|
||||
}
|
||||
|
||||
if constexpr (!NOEXCEPT) {
|
||||
throw std::error_code(err, XCLIBErrorCategory::get());
|
||||
throw std::system_error(err, XCLIBErrorCategory::get());
|
||||
}
|
||||
} else {
|
||||
if (std::ranges::size(func_name)) {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include <common/adc_spdlog.h>
|
||||
#include <common/adc_utils.h>
|
||||
#include <net/adc_netproto.h>
|
||||
#include <net/asio/adc_device_netserver_asio.h>
|
||||
#include <spdlog/sinks/basic_file_sink.h>
|
||||
@ -76,38 +77,31 @@ int main(int argc, char* argv[])
|
||||
}();
|
||||
|
||||
std::string level_str = opt_result["level"].as<std::string>();
|
||||
std::ranges::transform(level_str, level_str.begin(), [](const char& c) { return std::tolower(c); });
|
||||
|
||||
auto log_level = [&level_str]() {
|
||||
if (level_str == "TRACE") {
|
||||
return spdlog::level::trace;
|
||||
} else if (level_str == "DEBUG") {
|
||||
return spdlog::level::debug;
|
||||
} else if (level_str == "INFO") {
|
||||
return spdlog::level::info;
|
||||
} else if (level_str == "WARN") {
|
||||
return spdlog::level::warn;
|
||||
} else if (level_str == "ERROR") {
|
||||
return spdlog::level::err;
|
||||
} else if (level_str == "CRITICAL") {
|
||||
return spdlog::level::critical;
|
||||
} else if (level_str == "OFF") {
|
||||
return spdlog::level::off;
|
||||
}
|
||||
|
||||
return spdlog::level::info;
|
||||
}();
|
||||
auto log_level = spdlog::level::from_str(level_str);
|
||||
|
||||
logger->set_level(log_level);
|
||||
|
||||
logger->flush_on(spdlog::level::trace);
|
||||
|
||||
logger->set_pattern("%v");
|
||||
int w = 90;
|
||||
const std::string fmt = std::format("{{:*^{}}}", w);
|
||||
logger->info("\n\n\n");
|
||||
logger->info(fmt, "");
|
||||
logger->info(fmt, " RAPTOR EAGLE V CCD CAMERA SERVER ");
|
||||
auto zt = std::chrono::zoned_time(std::chrono::current_zone(),
|
||||
std::chrono::floor<std::chrono::seconds>(std::chrono::system_clock::now()));
|
||||
logger->info(fmt, std::format(" {} ", zt));
|
||||
logger->info(fmt, "");
|
||||
logger->info("\n");
|
||||
|
||||
asio::io_context io_ctx;
|
||||
|
||||
asio::signal_set signals(io_ctx, SIGINT, SIGTERM);
|
||||
signals.async_wait([&](std::error_code, int) { io_ctx.stop(); });
|
||||
|
||||
|
||||
RaptorEagleCCD ccd_device(logger);
|
||||
|
||||
server_t server("RAPTOR EAGLE V CCD SERVER", io_ctx, logger);
|
||||
@ -136,7 +130,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
if (opt_result["D"].as<bool>()) {
|
||||
// server.daemonize();
|
||||
server.daemonize();
|
||||
}
|
||||
|
||||
io_ctx.run();
|
||||
@ -145,13 +139,13 @@ int main(int argc, char* argv[])
|
||||
|
||||
} catch (const cxxopts::exceptions::exception& ex) {
|
||||
std::cerr << "\nAn error occured while parsing input options: " << ex.what() << "\n";
|
||||
return 127;
|
||||
exit_code = 127;
|
||||
} catch (const std::system_error& ex) {
|
||||
std::cerr << "\nAn error ocured: " << ex.what() << "\n";
|
||||
std::cerr << "Category: " << ex.code().category().name() << "; message: " << ex.code().message() << "\n";
|
||||
return 128;
|
||||
std::cerr << "\nAn error occured: " << ex.what() << " (err category: " << ex.code().category().name() << ")\n";
|
||||
// std::cerr << "Category: " << ex.code().category().name() << "; message: " << ex.code().message() << "\n";
|
||||
exit_code = 128;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user