diff --git a/camerad/CMakeLists.txt b/camerad/CMakeLists.txt index 7fbecc9..3cd43b6 100644 --- a/camerad/CMakeLists.txt +++ b/camerad/CMakeLists.txt @@ -128,6 +128,7 @@ list (APPEND INTERFACE_SOURCES add_library(${INTERFACE_TARGET} ${INTERFACE_SOURCES}) target_link_libraries(${INTERFACE_TARGET} common + shared_memory_writer ) target_include_directories(${INTERFACE_TARGET} PUBLIC ${INTERFACE_INCLUDES}) diff --git a/camerad/archon_controller.cpp b/camerad/archon_controller.cpp index 26b7109..cb22b6d 100644 --- a/camerad/archon_controller.cpp +++ b/camerad/archon_controller.cpp @@ -1640,6 +1640,15 @@ namespace Camera { logwrite(function, "applied mode geometry to controller"); } + for (const auto &[name, info] : mode->parammap) { + try { + this->set_parameter(name, std::stoi(info.value)); + } catch (const std::exception &e) { + logwrite(function, "ERROR applying mode param "+name+"="+info.value+": "+e.what()); + return ERROR; + } + } + return NO_ERROR; } /***** Camera::ArchonController::load_mode_settings *************************/ diff --git a/camerad/archon_controller.h b/camerad/archon_controller.h index 5ce1d01..1d61b69 100644 --- a/camerad/archon_controller.h +++ b/camerad/archon_controller.h @@ -294,7 +294,7 @@ namespace Camera { std::atomic_flag archon_busy = ATOMIC_FLAG_INIT; //!< indicates a thread is accessing Archon bool is_firmwareloaded; std::string firmware; - bool is_camera_mode; //!< has a camera mode been selected + bool is_camera_mode{false}; //!< has a camera mode been selected int msgref; std::string backplaneversion; std::vector modtype; //!< type of each module from SYSTEM command diff --git a/camerad/archon_interface.cpp b/camerad/archon_interface.cpp index 9e078ad..04cb665 100644 --- a/camerad/archon_interface.cpp +++ b/camerad/archon_interface.cpp @@ -807,12 +807,13 @@ namespace Camera { // if we made it all the way to the end then this is the selected mode this->controller->selectedmode = modeselect; + this->controller->is_camera_mode = true; - // Set the exposure mode to match the camera mode name if recognized - if (this->set_exposure_mode(modeselect, {}) != NO_ERROR) { - // Fall back to SINGLE if the camera mode name doesn't match an exposure mode - this->set_exposure_mode(std::string(ArchonExposureMode::SINGLE), {}); + std::string target = ArchonExposureMode::SINGLE; + for (const auto &m : this->get_exposure_modes()) { + if (m == modeselect) { target = modeselect; break; } } + this->set_exposure_mode(target, {}); return NO_ERROR; } diff --git a/camerad/camera_interface.h b/camerad/camera_interface.h index 3f96bf5..542986e 100644 --- a/camerad/camera_interface.h +++ b/camerad/camera_interface.h @@ -94,6 +94,10 @@ namespace Camera { virtual long do_expose() = 0; + /** @brief returns true if cmd is an instrument-specific command + */ + virtual bool is_instrument_command(const std::string &cmd) { return false; } + /** @brief returns error if not overridden */ virtual long instrument_cmd(const std::string &cmd, diff --git a/camerad/camera_server.cpp b/camerad/camera_server.cpp index 8cc34e4..0149c6f 100644 --- a/camerad/camera_server.cpp +++ b/camerad/camera_server.cpp @@ -223,6 +223,14 @@ namespace Camera { } ret = HELP; } + /** + * instrument-specific commands + */ + else + if (interface->is_instrument_command(cmd)) + { + ret = interface->instrument_cmd(cmd, args, retstring); + } else if ( cmd == CAMERAD_ABORT ) { ret = interface->abort(args, retstring); @@ -284,17 +292,7 @@ namespace Camera { if ( cmd == CAMERAD_TEST ) { ret = interface->test(args, retstring); } - /** - * instrument-specific commands - */ - else - if ( cmd == "hispec_this" ) { - ret = interface->instrument_cmd(cmd, args, retstring); - } - else - if ( cmd == "hispec_that" ) { - ret = interface->instrument_cmd(cmd, args, retstring); - } + /** * controller-specific commands */ @@ -326,6 +324,10 @@ namespace Camera { if ( cmd == "bob" ) { ret = interface->controller_cmd(cmd, args, retstring); } + else + if ( cmd == "autofetch_mode" ) { + ret = interface->controller_cmd(cmd, args, retstring); + } // unknown commands generate an error // diff --git a/utils/timing_stats.h b/utils/timing_stats.h index 7627620..61426c1 100644 --- a/utils/timing_stats.h +++ b/utils/timing_stats.h @@ -80,15 +80,15 @@ namespace Utils { return (1.0e6 * sd) / (m * m); } - [[nodiscard]] std::string summary() const { + [[nodiscard]] std::string summary(const std::string &label = "") const { std::ostringstream ss; - ss << std::fixed << std::setprecision(1) - << "median=" << median() << " us, " - << "mean=" << mean() << " us, " - << "jitter=" << jitter() << " us, " + ss << std::fixed << std::setprecision(1); + if (!label.empty()) ss << label << " "; + ss << "(n=" << count() << ")\n" + << " median=" << median() << "us mean=" << mean() << "us\n" + << " Jitter: peak2peak=" << jitter() << "us stddev=" << stddev() << "us\n" << std::setprecision(2) - << hertz() << " +/- " << hertz_stddev() << " Hz" - << " (n=" << count() << ")"; + << " Frequency: mean=" << hertz() << "Hz stddev=" << hertz_stddev() << "Hz"; return ss.str(); }