Commit fb51107a authored by Sebastien Petitdemange's avatar Sebastien Petitdemange Committed by Alejandro Homs Puron

Use the Macro THROW_CTRL instead of simple throw

parent aa2b8a2d
......@@ -426,10 +426,8 @@ void CtAccumulation::registerThresholdCallback(ThresholdCallback &cb)
m_cond.wait();
if(m_threshold_cb)
{
DEB_ERROR() << "ThresholdCallback already registered";
throw LIMA_CTL_EXC(InvalidValue, "ThresholdCallback already registered");
}
THROW_CTL_ERROR(InvalidValue) << "ThresholdCallback already registered";
m_threshold_cb = &cb;
}
......@@ -443,10 +441,8 @@ void CtAccumulation::unregisterThresholdCallback(ThresholdCallback &cb)
m_cond.wait();
if(m_threshold_cb != &cb)
{
DEB_ERROR() << "ThresholdCallback not registered";
throw LIMA_CTL_EXC(InvalidValue, "ThresholdCallback not registered");
}
THROW_CTL_ERROR(InvalidValue) << "ThresholdCallback not registered";
m_threshold_cb = NULL;
}
......
......@@ -28,13 +28,13 @@
{ \
DEB_ERROR() << "Specified " << DEB_VAR1(val) << " too short: " \
<< DEB_VAR1(m_valid_ranges.min_exp_time); \
throw LIMA_CTL_EXC(InvalidValue, "Exposure time too short"); \
THROW_CTL_ERROR(InvalidValue) << "Exposure time too short"; \
} \
else if (val > m_valid_ranges.max_exp_time) \
{ \
DEB_ERROR() << "Specified " << DEB_VAR1(val) << " too long: " \
<< DEB_VAR1(m_valid_ranges.max_exp_time); \
throw LIMA_CTL_EXC(InvalidValue, "Exposure time too long"); \
THROW_CTL_ERROR(InvalidValue) << "Exposure time too long"; \
}
using namespace lima;
......@@ -70,7 +70,7 @@ CtAcquisition::CtAcquisition(HwInterface *hw) :
DEB_CONSTRUCTOR();
if (!hw->getHwCtrlObj(m_hw_sync))
throw LIMA_CTL_EXC(Error, "Cannot get hardware sync object");
THROW_CTL_ERROR(Error) << "Cannot get hardware sync object";
m_valid_ranges_cb = new _ValidRangesCallback(*this);
m_hw_sync->getValidRanges(m_valid_ranges);
......@@ -480,7 +480,7 @@ void CtAcquisition::setLatencyTime(double lat_time)
if (lat_time < m_valid_ranges.min_lat_time)
lat_time = m_valid_ranges.min_lat_time;
if (lat_time > m_valid_ranges.max_lat_time)
throw LIMA_CTL_EXC(InvalidValue, "Latency time too long");
THROW_CTL_ERROR(InvalidValue) << "Latency time too long";
m_inpars.latencyTime= lat_time;
}
......
......@@ -58,7 +58,7 @@ CtBuffer::CtBuffer(HwInterface *hw)
DEB_CONSTRUCTOR();
if (!hw->getHwCtrlObj(m_hw_buffer))
throw LIMA_CTL_EXC(Error, "Cannot get hardware buffer object");
THROW_CTL_ERROR(Error) << "Cannot get hardware buffer object";
m_hw_buffer_cb = m_hw_buffer->getBufferCallback();
if(m_hw_buffer_cb)
......@@ -151,7 +151,7 @@ void CtBuffer:: setMaxMemory(short max_memory)
DEB_PARAM() << DEB_VAR1(max_memory);
if ((max_memory<1)||(max_memory>100))
throw LIMA_CTL_EXC(InvalidValue, "Max memory usage between 1 and 100");
THROW_CTL_ERROR(InvalidValue) << "Max memory usage between 1 and 100";
m_pars.maxMemory= max_memory;
}
......
......@@ -201,10 +201,10 @@ void CtControl::prepareAcq()
getStatus(aStatus);
if(aStatus.AcquisitionStatus == AcqRunning)
throw LIMA_CTL_EXC(Error,"Acquisition not finished");
THROW_CTL_ERROR(Error) << "Acquisition not finished";
if(aStatus.AcquisitionStatus == AcqConfig)
throw LIMA_CTL_EXC(Error,"Configuration not finished");
THROW_CTL_ERROR(Error) << "Configuration not finished";
resetStatus(false);
......@@ -288,7 +288,7 @@ void CtControl::startAcq()
DEB_MEMBER_FUNCT();
if (!m_ready)
throw LIMA_CTL_EXC(Error, "Run prepareAcq before starting acquisition");
THROW_CTL_ERROR(Error) << "Run prepareAcq before starting acquisition";
m_running = true;
TrigMode trigMode;
m_ct_acq->getTriggerMode(trigMode);
......@@ -301,7 +301,7 @@ void CtControl::startAcq()
HwInterface::Status hwStatus;
m_hw->getStatus(hwStatus);
if(hwStatus.det != DetIdle)
throw LIMA_CTL_EXC(Error, "Try to restart before detector is ready");
THROW_CTL_ERROR(Error) << "Try to restart before detector is ready";
//m_ready = false after the last image is triggerred
int nbFrames4Acq;
......@@ -443,9 +443,9 @@ void CtControl::ReadImage(Data &aReturnData,long frameNumber,
else
{
if(frameNumber < m_status.ImageCounters.LastImageReady - m_images_buffer_size)
throw LIMA_CTL_EXC(Error,"Frame no more available");
THROW_CTL_ERROR(Error) << "Frame no more available";
else
throw LIMA_CTL_EXC(Error,"Frame not available yet");
THROW_CTL_ERROR(Error) << "Frame not available yet";
}
}
else
......@@ -479,9 +479,9 @@ void CtControl::ReadBaseImage(Data &aReturnData,long frameNumber,
if (frameNumber < 0) {
frameNumber = lastFrame - (readBlockLen - 1);
if (frameNumber < 0)
throw LIMA_CTL_EXC(Error, "Frame(s) not available yet");
THROW_CTL_ERROR(Error) << "Frame(s) not available yet";
} else if (frameNumber + readBlockLen - 1 > lastFrame)
throw LIMA_CTL_EXC(Error, "Frame(s) not available yet");
THROW_CTL_ERROR(Error) << "Frame(s) not available yet";
aLock.unlock();
m_ct_buffer->getFrame(aReturnData,frameNumber,readBlockLen);
......@@ -491,7 +491,7 @@ void CtControl::ReadBaseImage(Data &aReturnData,long frameNumber,
int roiHeight = img_dim.getSize().getHeight() * readBlockLen;
if((roiWidth * roiHeight) >
(aReturnData.dimensions[0] * aReturnData.dimensions[1]))
throw LIMA_CTL_EXC(Error, "Roi dim > HwBuffer dim");
THROW_CTL_ERROR(Error) << "Roi dim > HwBuffer dim";
aReturnData.dimensions[0] = roiWidth;
aReturnData.dimensions[1] = roiHeight;
......@@ -733,7 +733,7 @@ void CtControl::registerImageStatusCallback(ImageStatusCallback& cb)
if (m_img_status_cb) {
DEB_ERROR() << "ImageStatusCallback already registered";
throw LIMA_CTL_EXC(InvalidValue, "ImageStatusCallback already registered");
THROW_CTL_ERROR(InvalidValue) << "ImageStatusCallback already registered";
}
cb.setImageStatusCallbackGen(this);
......@@ -747,7 +747,7 @@ void CtControl::unregisterImageStatusCallback(ImageStatusCallback& cb)
if (m_img_status_cb != &cb) {
DEB_ERROR() << "ImageStatusCallback not registered";
throw LIMA_CTL_EXC(InvalidValue, "ImageStatusCallback not registered");
THROW_CTL_ERROR(InvalidValue) << "ImageStatusCallback not registered";
}
m_img_status_cb = NULL;
......
......@@ -124,8 +124,8 @@ void CtSaving::Parameters::checkValid() const
#ifdef WITH_CBF_SAVING
case CBFFormat :
if(framesPerFile > 1)
throw LIMA_CTL_EXC(InvalidValue, "CBF file format does not support "
"multi frame per file");
THROW_CTL_ERROR(InvalidValue) << "CBF file format does not support "
"multi frame per file";
break;
#endif
#ifndef __unix
......
......@@ -117,13 +117,13 @@ public:
if(_fillHeader(aData,m_header,cbf))
{
cbf_free_handle(cbf);
throw LIMA_CTL_EXC(Error,"Something went wrong during CBF header filling");
THROW_CTL_ERROR(Error) << "Something went wrong during CBF header filling";
}
if(_fillData(aData,cbf))
{
cbf_free_handle(cbf);
throw LIMA_CTL_EXC(Error,"Something went wrong during CBF data filling");
THROW_CTL_ERROR(Error) << "Something went wrong during CBF data filling";
}
m_container._setHandle(aData.frameNumber,cbf);
}
......@@ -250,7 +250,7 @@ void SaveContainerCbf::_writeFile(Data &aData,
CtSaving::FileFormat)
{
if(_writeCbfData(aData))
throw LIMA_CTL_EXC(Error,"Something went wrong during CBF data writing");
THROW_CTL_ERROR(Error) << "Something went wrong during CBF data writing";
}
void SaveContainerCbf::_clear()
......
......@@ -136,7 +136,7 @@ void SaveContainerFits::_writeFile(Data &aData,
bitpixName = "DOUBLE_IMG";
break;
default:
throw LIMA_CTL_EXC(Error, "Can't determine bitpix");
THROW_CTL_ERROR(Error) << "Can't determine bitpix";
}
DEB_TRACE() << "SaveContainerFits::_writeFile(): used bitpix: " << bitpixName << "(" << bitpix << ")";
......@@ -154,7 +154,7 @@ void SaveContainerFits::_writeFile(Data &aData,
}catch(CCfits::FITS::CantCreate)
{
throw LIMA_CTL_EXC(Error, "Can't create FITS file");
THROW_CTL_ERROR(Error) << "Can't create FITS file";
}
delete naxes;
......
......@@ -153,12 +153,12 @@ void SaveContainerNxs::_writeFile(Data &aData,
my_error<<ex.errors[i].desc;
}
DEB_TRACE()<<my_error.str();
throw LIMA_CTL_EXC(Error,my_error.str());
THROW_CTL_ERROR(Error) << my_error.str();
}
catch(...)
{
DEB_TRACE()<<"SaveContainerNxs::_writeFile() - catch UNKNOWN Exception";
throw LIMA_CTL_EXC(Error,"SaveContainerNxs::_writeFile() - catch UNKNOWN Exception");
THROW_CTL_ERROR(Error) << "SaveContainerNxs::_writeFile() - catch UNKNOWN Exception";
}
}
......
......@@ -30,7 +30,7 @@ using namespace lima;
if(m_has_shutter)\
func; \
else\
throw LIMA_CTL_EXC(Error, "No shutter capability");
THROW_CTL_ERROR(Error) << "No shutter capability";
CtShutter::CtShutter(HwInterface *hw)
{
......
......@@ -316,6 +316,7 @@ void CtVideo::getParameters(Parameters &pars) const
void CtVideo::_setLive(bool liveFlag)
{
DEB_MEMBER_FUNCT();
AutoMutex aLock(m_cond.mutex());
while(m_stopping_live) m_cond.wait();
......@@ -326,7 +327,7 @@ void CtVideo::_setLive(bool liveFlag)
CtControl::Status status;
m_ct.getStatus(status);
if(liveFlag && status.AcquisitionStatus != AcqReady)
throw LIMA_CTL_EXC(Error, "Can't set live mode if an acquisition is running");
THROW_CTL_ERROR(Error) << "Can't set live mode if an acquisition is running";
_apply_params(aLock,liveFlag);
......@@ -385,10 +386,11 @@ void CtVideo::getExposure(double &anExposure) const
void CtVideo::setGain(double aGain)
{
DEB_MEMBER_FUNCT();
if(!m_has_video)
throw LIMA_CTL_EXC(Error,"Can't change the gain on Scientific camera");
THROW_CTL_ERROR(Error) << "Can't change the gain on Scientific camera";
if(aGain < 0. || aGain > 1.)
throw LIMA_CTL_EXC(InvalidValue,"Gain should be between 0. and 1.");
THROW_CTL_ERROR(InvalidValue) << "Gain should be between 0. and 1.";
AutoMutex aLock(m_cond.mutex());
m_pars.gain = aGain,m_pars_modify_mask |= PARMODIFYMASK_GAIN;
......@@ -471,7 +473,7 @@ void CtVideo::registerImageCallback(ImageCallback &cb)
if(m_image_callback)
{
DEB_ERROR() << "ImageCallback already registered";
throw LIMA_CTL_EXC(InvalidValue, "ImageCallback already registered");
THROW_CTL_ERROR(InvalidValue) << "ImageCallback already registered";
}
m_image_callback = &cb;
......@@ -486,7 +488,7 @@ void CtVideo::unregisterImageCallback(ImageCallback &cb)
if(m_image_callback != &cb)
{
DEB_ERROR() << "ImageCallback not registered";
throw LIMA_CTL_EXC(InvalidValue, "ImageCallback not registered");
THROW_CTL_ERROR(InvalidValue) << "ImageCallback not registered";
}
m_image_callback = NULL;
......@@ -522,8 +524,7 @@ void CtVideo::getSupportedVideoMode(std::list<VideoMode> &modeList)
case Bpp32S:
modeList.push_back(Y32); break;
default:
DEB_ERROR() << "Image type not yet managed";
throw LIMA_CTL_EXC(Error, "Image type not yet managed");
THROW_CTL_ERROR(Error) << "Image type not yet managed";
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment