Skip to content
Draft
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
1 change: 1 addition & 0 deletions camerad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ elseif (CONTROLLER STREQUAL "archon")
${CAMERAD_DIR}/archon_interface.cpp
${CAMERAD_DIR}/archon_controller.cpp
${CAMERAD_DIR}/archon_exposure_modes.cpp
${CAMERAD_DIR}/archon_exposure_modes_rxrv.cpp
)
# ----------------------------------------------------------------------------
# AstroCam ARC-64/66 PCI/e
Expand Down
11 changes: 11 additions & 0 deletions camerad/Instruments/cryoscope/cryoscope.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ----------------------------------------------------------------------------
# @file Instruments/cryoscope/cryoscope.cmake
# @brief CryoScope-specific input to the CMake build system for camerad
# @author David Hale <dhale@caltech.edu>
# ----------------------------------------------------------------------------

set (INSTRUMENT_SOURCES
${CAMERAD_DIR}/Instruments/cryoscope/cryoscope_instrument.cpp
${CAMERAD_DIR}/Instruments/cryoscope/cryoscope_interface_factory.cpp
${CAMERAD_DIR}/Instruments/cryoscope/cryoscope_exposure_modes.cpp
)
44 changes: 44 additions & 0 deletions camerad/Instruments/cryoscope/cryoscope_exposure_modes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @file Instruments/cryoscope/cryoscope_exposure_modes.h
* @brief implements CryoScope-specific exposure modes
*
*/

#include "archon_exposure_modes.h"
#include "cryoscope_exposure_modes.h"
#include "archon_interface.h"

namespace Camera {

/***** Camera::ExposureModeXXX::expose *************************************/
/**
* @brief implementation of cryoscope-specific expose for a non-standard mode
*
*/
long ExposureModeXXX::expose() {
const std::string function("Camera::ExposureModeXXX::expose");
logwrite(function, "meep meep");
return NO_ERROR;
}
/***** Camera::ExposureModeXXX::expose *************************************/


/***** Camera::ExposureModeXXX::image_acquisition_thread ********************/
/**
* @brief producer thread for non-standard ExposureMode XXX
* @details Spawned by Camera::ArchonInterface::do_expose()
*
*/
void ExposureModeXXX::image_acquisition_thread() {
const std::string function("Camera::ExposureModeXXX::image_acquisition_thread");
char message[256];

logwrite(function, "mode args:");

for (const auto &arg : this->modeargs) {
logwrite(function, arg);
}
}
/***** Camera::ExposureModeXXX::image_acquisition_thread ********************/

}
45 changes: 45 additions & 0 deletions camerad/Instruments/cryoscope/cryoscope_exposure_modes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @file Instruments/cryoscope/cryoscope_exposure_modes.h
* @brief delcares CryoScope-specific exposure mode classes
* @details Declares classes that implement exposure modes supported by
* CryoScope. These classes override virtual functions in the
* ExposureMode base class to provide mode-specific behavior.
*
*/

#pragma once

#include "exposure_modes.h" // ExposureMode base class

namespace Camera {

/**
* @namespace all recognized exposure modes for CryoScope
*/
namespace CryoScopeExposureMode {
constexpr const char* XXX = "XXX";
constexpr const char* ALLMODES[] = {XXX};
}

class CryoScope;

/**
* @brief class constructor example for cryoscope-specific non-standard mode XXX
* @param[in] _interface Pointer to Camera InterfaceType
* @param[in] _modeargs mode arguments
*/
class ExposureModeXXX : public ExposureModeTemplate<Camera::ArchonInterface,
Camera::ArchonImageBuffer> {
public:
ExposureModeXXX(Camera::ArchonInterface* iface, std::vector<std::string> modeargs)
: ExposureModeTemplate<Camera::ArchonInterface,
Camera::ArchonImageBuffer>(iface) {
this->modetype = CryoScopeExposureMode::XXX;
this->modeargs = std::move(modeargs);
}

long expose() override;
void image_acquisition_thread() override;
};

}
173 changes: 173 additions & 0 deletions camerad/Instruments/cryoscope/cryoscope_instrument.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/**
* @file Instruments/cryoscope/cryoscope_instrument.cpp
* @brief implementation for CryoScope-specific properties
* @author David Hale <dhale@astro.caltech.edu>
*
*/

#include "cryoscope_instrument.h"
#include "cryoscope_exposure_modes.h"

namespace Camera {

/***** Camera::CryoScope::instrument_cmd ************************************/
/**
* @brief dispatcher for CryoScope-specific instrument commands
* @details This allows dispatching instrument specific commands by receiving
* the command and args and calling the appropriate instrument
* specific function.
* @param[in] cmd command
* @param[in] args any number of arguments
* @param[out] retstring return string
* @return ERROR|NO_ERROR|HELP
*
*/
long CryoScope::instrument_cmd(const std::string &cmd,
const std::string &args,
std::string &retstring) {
if (false) {
}
else {
retstring = "unrecognized command";
return ERROR;
}
}
/***** Camera::CryoScope::instrument_cmd ************************************/


/***** Camera::CryoScope::configure_instrument ******************************/
/**
* @brief extract+apply instrument-specific parameters from config file
* @throws std::runtime_error
*
*/
void CryoScope::configure_instrument() {
const std::string function("Camera::CryoScope::configure_instrument");
int numapplied=0, lastapplied=0;

if (this->configfile.n_rows < 1) throw std::runtime_error("empty configuration");

// iterate through each row in config file
for (int row=0; row < this->configfile.n_rows; row++) {

lastapplied=numapplied;

// START_PARAM
if (this->configfile.param[row]=="START_PARAM") {
this->start_param = this->configfile.arg[row];
numapplied++;
}

if (numapplied > lastapplied) {
std::ostringstream oss;
oss << "config:" << this->configfile.param[row] << "=" << this->configfile.arg[row];
logwrite(function, oss.str());
}
}
}
/***** Camera::CryoScope::configure_instrument ******************************/


/***** Camera::CryoScope::power *********************************************/
/**
* @brief set/get power and set Start=1 when powered on
* @details This overrides ArchonInterface::power. It calls the standard function,
* but if powered on then it also sets the Start parameter = 1
* @param[in] args requested state or help, on|off|?
* @param[out] retstring contains power_status string on success
* @return ERROR | NO_ERROR | HELP
*
*/
long CryoScope::power(const std::string args, std::string &retstring) {

// first call standard ArchonInterface power
long error = this->ArchonInterface::power(args, retstring);

// if power is turned on set Start=1 and setup detector
if (error==NO_ERROR && !args.empty() && this->controller->power_status=="ON") {
error = this->controller->set_parameter(this->start_param, 1);
if (error==NO_ERROR) error = this->setup_detector();
}
else
// if power is turned off set Start=0
if (error==NO_ERROR && !args.empty() && this->controller->power_status=="OFF") {
error = this->controller->set_parameter(this->start_param, 0);
}

return error;
}
/***** Camera::CryoScope::power *********************************************/


/***** Camera::CryoScope::get_exposure_modes ********************************/
/**
* @brief return a vector of strings of recognized exposure modes
* @details This adds CryoScope exposure modes to the base exposure modes.
* @return vector<string>
*
*/
std::vector<std::string> CryoScope::get_exposure_modes() {
// base exposure modes
auto modes = this->ArchonInterface::get_exposure_modes();

// add cryoscope exposure modes
for (const auto &mode : Camera::CryoScopeExposureMode::ALLMODES) { modes.push_back(mode); }

return modes;
}
/***** Camera::CryoScope::get_exposure_modes ********************************/


/***** Camera::CryoScope::set_exposure_mode *********************************/
/**
* @brief actually sets the exposure mode
* @details This creates the appropriate exposure mode object for the
* requested exposure mode, providing access to that mode's functions.
* This is cryoscope-specific but gets called by ArchonInterface because
* it overrides. If the requested mode is not a cryoscope mode then
* this will call the set_exposure_mode in the base class.
* @param[in] modein desired exposure mode
* @param[in] modeargs optional arguments for the mode
* @return ERROR|NO_ERROR
*
*/
long CryoScope::set_exposure_mode(const std::string &modein, const std::vector<std::string> &modeargs) {

// check for specialized cryoscope-specific expose modes
if (caseCompareString(modein, CryoScopeExposureMode::XXX)) {
this->exposuremode = std::make_unique<ExposureModeXXX>(this, modeargs);
}
// otherwise it's a standard ArchonInterface exposure mode
else {
return this->ArchonInterface::set_exposure_mode(modein, modeargs);
}

return NO_ERROR;
}
/***** Camera::CryoScope::set_exposure_mode *********************************/


/***** Camera::CryoScope::setup_detector ************************************/
/**
* @brief setup detector
* @details This is a hard-coded placeholder for a better version but
* here just so the detector works.
* @return ERROR|NO_ERROR
*
*/
long CryoScope::setup_detector() {
long error=NO_ERROR;
std::vector<std::string> commands = { "10 1 16402",
"10 0 1",
"10 0 0" };
for (const auto &cmd : commands) {
error = this->controller->set_vcpu_inreg(cmd);
if (error!=NO_ERROR) break;
std::this_thread::sleep_for(std::chrono::seconds(1));
}

return error;
}
/***** Camera::CryoScope::setup_detector ************************************/

}
39 changes: 39 additions & 0 deletions camerad/Instruments/cryoscope/cryoscope_instrument.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @file Instruments/cryoscope/cryoscope_instrument.h
* @brief contains properties unique to the CryoScope instrument
* @author David Hale <dhale@astro.caltech.edu>
*
*/
#pragma once

#include "archon_interface.h" /// CryoScope uses ArchonInteface

namespace Camera {

/***** Camera::CryoScope ****************************************************/
/**
* @class CryoScope
* @brief derived class inherits from ArchonInterface
* @details This class describes CryoScope-specific functionality.
*
*/
class CryoScope : public ArchonInterface {
public:
// instrument command dispatcher
long instrument_cmd(const std::string &cmd,
const std::string &args,
std::string &retstring) override;

void configure_instrument() override;
long power(std::string args, std::string &retstring) override;

std::vector<std::string> get_exposure_modes() override;
long set_exposure_mode(const std::string &modein, const std::vector<std::string> &args) override;

private:
// these are CryoScope-specific functions
std::string start_param;
long setup_detector();
};
/***** Camera::CryoScope ****************************************************/
}
23 changes: 23 additions & 0 deletions camerad/Instruments/cryoscope/cryoscope_interface_factory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @file Instruments/cryoscope/cryoscope_interface_factory.cpp
* @brief CryoScope Interface Factory
* @author David Hale <dhale@astro.caltech.edu>
*
*/
#include "cryoscope_instrument.h"
#include "camera_interface.h"

namespace Camera {

/***** Camera::Interface::create ********************************************/
/**
* @brief factory function to create pointer to CryoScope
* @return unique_ptr<CryoScope>
*
*/
std::unique_ptr<Interface> Interface::create() {
return std::make_unique<CryoScope>();
}
/***** Camera::Interface::create ********************************************/

}
2 changes: 0 additions & 2 deletions camerad/archon_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1855,8 +1855,6 @@ namespace Camera {
int num_detect = this->modemap[this->selectedmode].geometry.num_detect;
auto index = this->frameinfo.index.load();

logwrite(function, "");

this->frametype = type;

// Archon buffer number of the last frame read into memory
Expand Down
Loading