Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions camerad/archon_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ namespace Camera {
do_expose();
}

this->end_exposure();

return NO_ERROR;
}
/***** Camera::ArchonInterface::expose **************************************/
Expand Down
2 changes: 2 additions & 0 deletions camerad/camera_information.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace Camera {
Common::FitsKeys userkeys; //!< FITS keys for command line use
Common::FitsKeys systemkeys; //!< FITS keys for system use

bool is_datacube{false}; //!< true: reads written as extensions of one multi-extension FITS file

std::vector<uint32_t> naxes; //!< axis lengths element 0=cols, 1=rows, 2=cubedepth
std::array<uint32_t,2> binning;
std::array<uint32_t,4> region_of_interest;
Expand Down
74 changes: 74 additions & 0 deletions camerad/camera_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "camera_interface.h"

#include <algorithm>
#include <cctype>

namespace Camera {

// this is the code for shared functions common to all implementations
Expand All @@ -25,4 +28,75 @@ namespace Camera {
this->disconnect_controller("", retstring);
}
/***** Camera::Interface::disconnect_controller *****************************/


/***** Camera::Interface::key *************************************************/
/**
* @brief add/list a custom FITS keyword written into every exposure
* @param[in] args "list", or "KEYWORD=VALUE//COMMENT" (comment optional)
* @param[out] retstring usage string on help/error
* @return NO_ERROR | ERROR | HELP
*
* KEYWORD=. deletes that keyword (see Common::FitsKeys::addkey).
*
*/
long Interface::key(std::string args, std::string &retstring) {
const std::string function("Camera::Interface::key");

if (args.empty() || args == "?" || args == "help") {
retstring = "key KEYWORD=VALUE//COMMENT | key list";
return HELP;
}

if (args == "list") {
logwrite(function, "systemkeys:");
this->camera_info.systemkeys.listkeys();
logwrite(function, "userkeys:");
this->camera_info.userkeys.listkeys();
return NO_ERROR;
}

long error = this->camera_info.userkeys.addkey(args);
if (error != NO_ERROR) {
logwrite(function, "ERROR bad syntax: expected KEYWORD=VALUE//COMMENT");
}
return error;
}
/***** Camera::Interface::key *************************************************/


/***** Camera::Interface::datacube *********************************************/
/**
* @brief set/report whether reads are written as one multi-extension FITS file
* @param[in] args "true", "false" (case-insensitive), or empty to report state
* @param[out] retstring current state ("true"/"false"), or usage on error
* @return NO_ERROR | ERROR | HELP
*
*/
long Interface::datacube(std::string args, std::string &retstring) {
const std::string function("Camera::Interface::datacube");

if (args == "?" || args == "help") {
retstring = "datacube [ true | false ]";
return HELP;
}

if (!args.empty()) {
std::transform(args.begin(), args.end(), args.begin(),
[](unsigned char c) { return std::tolower(c); });
if (args != "true" && args != "false") {
retstring = "datacube [ true | false ]";
logwrite(function, "ERROR expected true or false, got " + args);
return ERROR;
}
this->camera_info.is_datacube = (args == "true");
for (auto &output : this->frame_outputs) {
output->set_option("datacube", args);
}
}

retstring = (this->camera_info.is_datacube ? "true" : "false");
return NO_ERROR;
}
/***** Camera::Interface::datacube *********************************************/
}
10 changes: 9 additions & 1 deletion camerad/camera_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,22 @@ namespace Camera {
output->write(data, size, meta);
}
}
// Common::FitsKeys systemkeys; move to Camera::Information?

// Tell every FrameOutput the current exposure command has finished
void end_exposure() {
for (auto &output : this->frame_outputs) {
output->end_exposure();
}
}

// These functions are shared by all interfaces with common implementations,
// and are implemented in camera_interface.cpp
//
void set_server(Camera::Server* s);
void func_shared();
void disconnect_controller();
long key(std::string args, std::string &retstring);
long datacube(std::string args, std::string &retstring);
bool is_exposuremode_set() { return ( this->exposuremode && !this->exposuremode->get_type().empty() ); }

void set_abortstate() { this->abortstate.store(true, std::memory_order_seq_cst); }
Expand Down
8 changes: 8 additions & 0 deletions camerad/camera_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ namespace Camera {
if ( cmd == CAMERAD_TEST ) {
ret = interface->test(args, retstring);
}
else
if ( cmd == CAMERAD_KEY ) {
ret = interface->key(args, retstring);
}
else
if ( cmd == CAMERAD_DATACUBE ) {
ret = interface->datacube(args, retstring);
}

/**
* controller-specific commands
Expand Down
2 changes: 2 additions & 0 deletions common/camerad_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const std::string CAMERAD_BOI("boi");
const std::string CAMERAD_BUFFER("buffer");
const std::string CAMERAD_CLOSE("close");
const std::string CAMERAD_CONFIG("config");
const std::string CAMERAD_DATACUBE("datacube");
const std::string CAMERAD_ECHO("echo");
const std::string CAMERAD_EXIT("exit");
const std::string CAMERAD_EXPOSE("expose");
Expand Down Expand Up @@ -64,6 +65,7 @@ const std::vector<std::string> CAMERAD_SYNTAX = {
CAMERAD_BUFFER+" ? | <dev#> | <chan> [ <bytes> | <cols> <rows> ]",
CAMERAD_CLOSE,
CAMERAD_CONFIG,
CAMERAD_DATACUBE+" [ true | false ]",
CAMERAD_ECHO,
CAMERAD_EXPOSE,
CAMERAD_EXPOSUREMODE,
Expand Down
7 changes: 0 additions & 7 deletions utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ target_link_libraries(fits_writer
${FITSWRITER_CFITS_LIB}
)

add_library(cadence_gate STATIC
${PROJECT_UTILS_DIR}/cadence_gate.cpp
)
target_include_directories(cadence_gate PRIVATE ${PROJECT_BASE_DIR}/common ${PROJECT_BASE_DIR}/utils)
target_link_libraries(cadence_gate nlohmann_json::nlohmann_json)

add_library(frame_output_factory STATIC
${PROJECT_UTILS_DIR}/frame_output_factory.cpp
)
Expand All @@ -55,7 +49,6 @@ target_link_libraries(frame_output_factory
nlohmann_json::nlohmann_json
shared_memory_writer
fits_writer
cadence_gate
)

add_library(md5 STATIC
Expand Down
36 changes: 0 additions & 36 deletions utils/cadence_gate.cpp

This file was deleted.

46 changes: 0 additions & 46 deletions utils/cadence_gate.h

This file was deleted.

Loading
Loading