Skip to content
Closed
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
31 changes: 29 additions & 2 deletions camerad/archon_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@

namespace Camera {

namespace {
struct CommandTimeout {
std::string_view command;
int timeout_ms;
};

// STA's own values, from the timeouts archongui passes interfaceCommand
constexpr std::array<CommandTimeout, 6> COMMAND_TIMEOUTS {{
{"ERASESTOREDCONFIG", 60000},
{"FLASHACTIVECONFIG", 60000},
{"APPLYALL", 30000},
{"POWERON", 30000},
{"POWEROFF", 30000},
{"LOADTIMING", 5000},
}};

int timeout_for(const std::string &cmd) {
const size_t end = cmd.find(' ');
const std::string_view verb(cmd.data(), end == std::string::npos ? cmd.size() : end);
for (const auto &entry : COMMAND_TIMEOUTS) {
if (entry.command == verb) return entry.timeout_ms;
}
return Network::POLLTIMEOUT;
}
}


/***** Camera::ArchonController::ArchonController ***************************/
/**
Expand Down Expand Up @@ -1114,9 +1140,10 @@ namespace Camera {
constexpr size_t BUFSZ = 64*1024;
auto buffer = std::make_unique<char[]>(BUFSZ+1);
reply.clear();
const int timeout_ms = timeout_for(cmd);
do {
if ( (retval=this->archon.Poll()) <= 0) {
if (retval==0) { logwrite(function, "Poll timeout waiting for response from Archon command (maybe unrecognized command?)"); error=TIMEOUT; }
if ( (retval=this->archon.Poll(timeout_ms)) <= 0) {
if (retval==0) { logwrite(function, "Poll timeout after "+std::to_string(timeout_ms)+"ms waiting for response to \""+cmd+"\""); error=TIMEOUT; }
if (retval<0) { logwrite(function, "Poll error waiting for response from Archon command"); error=ERROR; }
break;
}
Expand Down
24 changes: 11 additions & 13 deletions camerad/archon_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,36 +708,34 @@ namespace Camera {
retstring.append( " Archon power will be off after this operation.\n" );
return HELP;
}
// call the work function
return load_firmware(args);
}
/***** Camera::ArchonInterface::load_firmware *******************************/
/**
* @brief loads the ACF file and applies the complete Archon Configuration
* @param[in] args fully qualified path of ACF
* @return ERROR|NO_ERROR
*
*/
long ArchonInterface::load_firmware(const std::string &acffile) {

const std::string function("Camera::ArchonInterface::load_firmware");
const std::string &acffile = args;
logwrite(function, acffile);

// load the ACF file and write to Archon configuration memory
//
long error = this->controller->load_acf(acffile);
if (error != NO_ERROR) retstring = "writing the ACF to configuration memory";

// Parse and apply the complete system configuration from configuration memory.
// Detector power will be off after this.
//
if (error == NO_ERROR) error = this->controller->send_cmd(APPLYALL);
if (error == NO_ERROR) {
error = this->controller->send_cmd(APPLYALL);
if (error != NO_ERROR) retstring = "applying the configuration (APPLYALL)";
}

// read/clear Archon's internal error log
//
if (error != NO_ERROR) this->controller->fetchlog();

// set the mode to DEFAULT
//
if (error == NO_ERROR) error = this->set_camera_mode(std::string("DEFAULT"));
if (error == NO_ERROR) {
error = this->set_camera_mode(std::string("DEFAULT"));
if (error != NO_ERROR) retstring = "selecting the DEFAULT mode";
}

// TODO set exptime
// TODO other instrument-specific defaults?
Expand Down
1 change: 0 additions & 1 deletion camerad/archon_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ namespace Camera {
// found in the base class.
//
long disconnect_controller();
long load_firmware(const std::string &acffile);
long allocate_framebuf(uint32_t reqsz);
long get_parameter(const std::string &args, std::string &retstring);
long load_timing(std::string cmd, std::string &reply);
Expand Down
Loading