// ============================================================================ // // = CONTEXT // TANGO Project - NovelecElectrometer Support Library // PhotoConducteur Types are Type 4 & 5 only // // = FILENAME // N_PhotoConducteur.cpp // // = AUTHOR // X. Elattaoui // // ============================================================================ // ============================================================================ // DEPENDENCIES // ============================================================================ #include <iostream> #include <sstream> #include <string> #include <Xstring.h> #include "N_PhotoConducteur.h" #include "NovelecProtocol.h" /* * Valid Range values for a N_PhotoConducteur */ static const std::string NType_4_rangeValue[] = {"100 MOhms","30 MOhms","10 MOhms","3 MOhms"}; static const std::string NType_5_rangeValue[] = {"1000 KOhms","300 KOhms","100 KOhms","30 KOhms"}; // ============================================================================ // N_PhotoConducteur::N_PhotoConducteur // ============================================================================ N_PhotoConducteur::N_PhotoConducteur (std::string& comLink_device_name, short address, short novTypeNumber) : Novelec_MCCE2(comLink_device_name, address, novTypeNumber) { //std::cout << "N_PhotoConducteur::N_PhotoConducteur <-" << std::endl; _rangeLimit = 3; //std::cout << "N_PhotoConducteur::N_PhotoConducteur ->" << std::endl; } // ============================================================================ // N_PhotoConducteur::~N_PhotoConducteur // ============================================================================ N_PhotoConducteur::~N_PhotoConducteur (void) { //std::cout << "N_PhotoConducteur::~N_PhotoConducteur <-" << std::endl; //std::cout << "N_PhotoConducteur::~N_PhotoConducteur ->" << std::endl; } // ============================================================================ // N_PhotoConducteur::range_up // ============================================================================ void N_PhotoConducteur::range_up (void) { std::stringstream cmd_to_send; _range += 1; if(_range > _rangeLimit) { _range = _rangeLimit; throw electrometer::ElectrometerException("OUT_OF_RANGE", "Range up limit reached.", "N_PhotoConducteur::range_up( )."); } //- build and send the command cmd_to_send << _range << std::endl; _electrometerProtocol->set_range(cmd_to_send.str()); } // ============================================================================ // N_PhotoConducteur::range_down // ============================================================================ void N_PhotoConducteur::range_down (void) { std::stringstream cmd_to_send; _range -= 1; if(_range < 0) { _range = 0; throw electrometer::ElectrometerException("OUT_OF_RANGE", "Range down limit reached.", "N_PhotoConducteur::range_down( )."); } //- build and send the command // _rangeStr = NType1_rangeValue[_range]; cmd_to_send << _range << std::endl; _electrometerProtocol->set_range(cmd_to_send.str()); } // ============================================================================ // N_PhotoConducteur::get_ElectroMeterGain // ============================================================================ std::string N_PhotoConducteur::get_ElectroMeterGain (void) { NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); if(!_nproto) throw electrometer::ElectrometerException("BAD_CAST", "Unable to query the electrmometer gain.", "N_PhotoConducteur::get_ElectroMeterGain( )."); return _nproto->get_gain(); } // ============================================================================ // N_PhotoConducteur::set_ElectroMeterGain // ============================================================================ void N_PhotoConducteur::set_ElectroMeterGain (std::string gain) { NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); if(!_nproto) throw electrometer::ElectrometerException("BAD_CAST", "INTERNAL ERROR : Unable to change the electrmometer function.", "N_PhotoConducteur::set_ElectroMeterGain( )."); _nproto->set_gain(gain); }