diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 4260f76..2698224 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -39,6 +39,7 @@ namespace Archon { this->is_longexposure_set = false; this->is_window = false; this->is_autofetch = false; + this->is_freerun = false; this->is_zmq = false; this->win_hstart = 0; this->win_hstop = 2047; @@ -4421,6 +4422,63 @@ long Interface::archon_cmd(std::string cmd, std::string &reply) { } /**************** Archon::Interface::autofetch *******************************/ + /**************** Archon::Interface::set_freerun *******************************/ + /** + * @fn set_freerun + * @brief turns freerun mode on and off + * @param set_state, string "TRUE, FALSE, 0, or 1" + * @return ERROR or NO_ERROR + * + * NOTE: Manipulates EXPOSE and Start Params and reloads acf file + */ + long Interface::set_freerun(std::string set_state){ + //Iniciate variables and messages for logs + std::string function = "Archon::Interface::set_freerun"; + std::stringstream message; + long error = NO_ERROR; + // If something is passed then try to use it to set the "freerun" state + // + if ( !set_state.empty() ) { + try { + std::transform( set_state.begin(), set_state.end(), set_state.begin(), ::toupper ); // make uppercase + std::string expose_param = "Expose"; + std::string start_param = "Start"; + long new_state; + if (set_state == "TRUE" || set_state == "1") { + //set expose and start on the archon or acf to 1 + new_state = 1; + error = this->set_parameter( expose_param, new_state); + if ( error == NO_ERROR ) error = this->set_parameter( start_param, new_state); + //log + this->is_freerun = true; + + } + else { + //set expose and start on acf or archon to 0 + new_state = 0; + error = this->set_parameter( expose_param, new_state); + if ( error == NO_ERROR ) error = this->set_parameter( start_param, new_state); + + //log + this->is_freerun = false; + } + } + catch (...) { + message.str(""); message << "unknown exception converting freerun state " << set_state << " to uppercase"; + this->camera.log_error( function, message.str() ); + return ERROR; + } + } + if (error != NO_ERROR) { + message.str(""); message << "setting freerun state to " << set_state; + this->camera.log_error( function, message.str() ); + return ERROR; + } + + return (error); + } + /**************** Archon::Interface::set_freerun *******************************/ + /**************** Archon::Interface::zmq ******************************/ /** * @fn zmq diff --git a/camerad/archon.h b/camerad/archon.h index b7f6067..779ec62 100644 --- a/camerad/archon.h +++ b/camerad/archon.h @@ -151,6 +151,7 @@ namespace Archon { bool is_longexposure_set; //!< true for long exposure mode (exptime in sec), false for exptime in msec bool is_window; //!< true if in window mode for h2rg, false if not bool is_autofetch; + bool is_freerun; bool is_zmq; int win_hstart; int win_hstop; @@ -281,6 +282,8 @@ namespace Archon { long autofetch(std::string state_in, std::string &state_out); + long set_freerun(std::string set_state); + long zmq(std::string state_in, std::string &state_out); long int write_to_zmq(const std::string& message); diff --git a/camerad/camerad.cpp b/camerad/camerad.cpp index beea774..66e6a04 100644 --- a/camerad/camerad.cpp +++ b/camerad/camerad.cpp @@ -628,8 +628,15 @@ void doit(Network::TcpSocket sock) { } else if (cmd == "abort") { server.camera.abort(); ret = 0; - } -#ifdef ASTROCAM + } //else if (cmd == "freerun") { + // server. + // TODO:: Add manipulating start = 1, expose = 1 and possibly mode_VideoRX to autofetch and non stop running + // Make start to 0 will stop the autofetch + // GOAL: Be able to turn auto fetch on and off dynamically. + // Must fetch very fast for tracking camera to grab + //} + + #ifdef ASTROCAM else if (cmd=="isopen") { ret = server.is_connected( retstring );