Commit 6c174052 authored by ahoms's avatar ahoms
Browse files

* fixed non-inited m_fout iostate crashing CtSaving::_SaveContainer::_open()

* fixed race condition in CtControl::getStatus between hw ready & newFrameReady
* fixed CtControl::newFrameReady not propagating event if not soft. tasks
* always sync to hw in CtHwBinRoi setBin/Roi to ensure proper hw calculations
* fixed [Frelon]TacoCcd set/getFilePar and InputChan
* reduced overhead calling Frelon::Camera::getInputChan in isChanActive
* fixed Frelon::Camera::getImageRoiOffset not taking into account curr. bin



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@206 45c4679d-1946-429d-baad-37912b19538b
parent e15a6d8c
......@@ -334,7 +334,7 @@ class TacoCcdAcq(TacoServer):
pars = CtSaving.Parameters()
overwrite = pars.overwritePolicy == CtSaving.Overwrite
arr = [pars.directory, pars.prefix, pars.suffix, pars.nextNumber,
pars.format, overwrite]
pars.fileFormat, overwrite]
par_arr = map(str, arr)
deb.Return('File pars: %s' % par_arr)
return par_arr
......
......@@ -222,17 +222,21 @@ class FrelonTacoAcq(TacoCcdAcq):
@DEB_MEMBER_FUNCT
def setFilePar(self, par_arr):
deb.Param('Setting file pars: %s' % pars)
deb.Param('Setting file pars: %s' % par_arr)
pars = CtSaving.Parameters()
pars.directory = par_arr[0]
pars.prefix = par_arr[1]
pars.suffix = par_arr[2]
pars.nextNumber = par_arr[3]
pars.format = CtSaving.EDF
pars.nextNumber = int(par_arr[3])
index_format = par_arr[4]
if par_arr[5] in ['y', 'yes']:
pars.overwrite = CtSaving.Overwrite
pars.overwritePolicy = CtSaving.Overwrite
else:
pars.overwrite = CtSaving.Abort
pars.overwritePolicy = CtSaving.Abort
if pars.suffix.lower()[-3:] == 'edf':
pars.fileFormat = CtSaving.EDF
else:
pars.fileFormat = CtSaving.RAW
ct_saving = self.m_acq.getSavingControl()
ct_saving.setParameters(pars)
......@@ -242,9 +246,10 @@ class FrelonTacoAcq(TacoCcdAcq):
pars = ct_saving.getParameters()
overwrite = (pars.overwritePolicy == CtSaving.Overwrite)
over_str = (overwrite and 'yes') or 'no'
index_format = '%04d'
arr = [pars.directory, pars.prefix, pars.suffix, pars.nextNumber,
pars.format, over_str]
par_arr = map(str, par_arr)
index_format, over_str]
par_arr = map(str, arr)
deb.Return('File pars: %s' % par_arr)
return par_arr
......@@ -252,7 +257,7 @@ class FrelonTacoAcq(TacoCcdAcq):
def setChannel(self, input_chan):
deb.Param('Setting input channel: %s' % input_chan)
cam = self.m_acq.getFrelonCamera()
cam.getInputChan(input_chan)
cam.setInputChan(int(input_chan))
@DEB_MEMBER_FUNCT
def getChannel(self):
......@@ -348,7 +353,10 @@ class FrelonTacoAcq(TacoCcdAcq):
@DEB_MEMBER_FUNCT
def setAutosave(self, autosave_act):
deb.Param('Setting autosave active: %s' % autosave_act)
saving_mode = (autosave_act and CtSaving.AutoFrame) or CtSaving.Manual
if autosave_act:
saving_mode = CtSaving.AutoFrame
else:
saving_mode = CtSaving.Manual
ct_saving = self.m_acq.getSavingControl()
ct_saving.setSavingMode(saving_mode)
......
......@@ -40,7 +40,7 @@ class Camera : public HwMaxImageSizeCallbackGen
void getFrameDim(FrameDim& frame_dim);
bool isChanActive(InputChan chan);
bool isChanActive(InputChan curr, InputChan chan);
void checkFlip(Flip& flip);
void setFlip(const Flip& flip);
......@@ -126,11 +126,9 @@ class Camera : public HwMaxImageSizeCallbackGen
bool m_mis_cb_act;
};
inline bool Camera::isChanActive(InputChan chan)
inline bool Camera::isChanActive(InputChan curr, InputChan chan)
{
InputChan curr_chan;
getInputChan(curr_chan);
return (curr_chan & chan) == chan;
return (curr & chan) == chan;
};
......
......@@ -428,8 +428,10 @@ void Camera::getRoiMode(RoiMode& roi_mode)
void Camera::getMirror(Point& mirror)
{
DEB_MEMBER_FUNCT();
mirror.x = isChanActive(Chan12) || isChanActive(Chan34);
mirror.y = isChanActive(Chan13) || isChanActive(Chan24);
InputChan curr;
getInputChan(curr);
mirror.x = isChanActive(curr, Chan12) || isChanActive(curr, Chan34);
mirror.y = isChanActive(curr, Chan13) || isChanActive(curr, Chan24);
DEB_RETURN() << DEB_VAR1(mirror);
}
......@@ -473,9 +475,11 @@ void Camera::xformChanCoords(const Point& point, Point& chan_point,
Size chan_size;
getChanSize(chan_size);
Flip readout_flip;
readout_flip.x = !(isChanActive(Chan1) || isChanActive(Chan3));
readout_flip.y = !(isChanActive(Chan1) || isChanActive(Chan2));
InputChan curr;
getInputChan(curr);
bool right = !isChanActive(curr, Chan1) && !isChanActive(curr, Chan3);
bool bottom = !isChanActive(curr, Chan1) && !isChanActive(curr, Chan2);
Flip readout_flip(right, bottom);
DEB_TRACE() << DEB_VAR2(chan_flip, readout_flip);
Flip effect_flip = chan_flip & readout_flip;
......@@ -579,6 +583,10 @@ void Camera::getImageRoiOffset(const Roi& req_roi, const Roi& image_roi,
Size ccd_size, image_size;
getCcdSize(ccd_size);
Bin bin;
getBin(bin);
ccd_size /= bin;
image_size = image_roi.getSize();
Point image_br = image_roi.getBottomRight() + 1;
......
......@@ -148,7 +148,7 @@ void test_frelon(bool do_reset)
string sep = "";
for (int i = 0; i < 4; i++) {
Frelon::InputChan chan = Frelon::InputChan(1 << i);
if (frelon_cam.isChanActive(chan)) {
if (frelon_cam.isChanActive(input_chan, chan)) {
cout << sep << (i + 1);
sep = "&";
}
......
......@@ -218,6 +218,8 @@ void CtControl::getStatus(Status& status) const
DEB_MEMBER_FUNCT();
AutoMutex aLock(m_cond.mutex());
DEB_TRACE() << DEB_VAR1(m_status.AcquisitionStatus);
if(m_status.AcquisitionStatus != AcqFault)
{
const ImageStatus &anImageCnt = m_status.ImageCounters;
......@@ -238,10 +240,17 @@ void CtControl::getStatus(Status& status) const
{
HwInterface::Status aHwStatus;
m_hw->getStatus(aHwStatus);
m_status.AcquisitionStatus = aHwStatus.acq; // set the status to hw acquisition status
// set the status to hw acquisition status
m_status.AcquisitionStatus = aHwStatus.acq;
int last_hw_frame = m_hw->getNbAcquiredFrames() - 1;
bool aFalseIdle = ((aHwStatus.acq == AcqReady) &&
(anImageCnt.LastImageAcquired != last_hw_frame));
if (aFalseIdle)
m_status.AcquisitionStatus = AcqRunning;
}
else
m_status.AcquisitionStatus = (aSavingIdleFlag || aProcessingIdle) ? AcqRunning : AcqReady;
m_status.AcquisitionStatus = AcqRunning;
}
......@@ -343,14 +352,8 @@ void CtControl::newFrameReady(Data& fdata)
PoolThreadMgr::get().addProcess(mgr);
else
delete mgr;
if (m_autosave && (!internal_stage && !last_link))
{
newFrameToSave(fdata);
AutoMutex aLock(m_cond.mutex());
ImageStatus &imgStatus = m_status.ImageCounters;
imgStatus.LastBaseImageReady = imgStatus.LastImageAcquired = fdata.frameNumber;
}
if (!internal_stage && !last_link)
newBaseImageReady(fdata);
if (m_img_status_cb)
m_img_status_cb->imageStatusChanged(m_status.ImageCounters);
......
......@@ -126,8 +126,13 @@ CtHwBinRoi::CtHwBinRoi(HwInterface *hw, CtSwBinRoi *sw_bin_roi, Size& size)
m_has_roi= hw->getHwCtrlObj(m_hw_roi);
m_has_flip= hw->getHwCtrlObj(m_hw_flip);
if (m_has_bin)
m_hw_bin->setBin(m_bin);
if (m_has_roi)
m_hw_roi->setRoi(m_set_roi);
m_max_size= size;
m_max_roi= Roi(Point(0,0), m_max_size);
m_max_roi= Roi(Point(0,0), m_max_size / m_bin);
m_size= m_max_size;
}
......@@ -168,7 +173,7 @@ void CtHwBinRoi::setBin(Bin& bin, bool round)
throw LIMA_CTL_EXC(NotSupported, "No hardware binning available");
}
else {
Bin set_bin(bin);
Bin set_bin= bin;
if (!set_bin.isOne())
m_hw_bin->checkBin(set_bin);
if ((!round)&&(set_bin!=bin))
......@@ -176,7 +181,10 @@ void CtHwBinRoi::setBin(Bin& bin, bool round)
if (set_bin != m_bin) {
if (!m_set_roi.isEmpty())
m_set_roi= m_set_roi.getUnbinned(m_bin);
m_hw_bin->setBin(set_bin);
m_bin= set_bin;
if (!m_bin.isOne() && !m_set_roi.isEmpty())
m_set_roi= m_set_roi.getBinned(m_bin);
m_max_roi.setSize(m_max_size / m_bin);
......@@ -206,6 +214,7 @@ void CtHwBinRoi::setRoi(Roi& roi, bool round)
if ((!round)&&(real_roi!=roi))
throw LIMA_CTL_EXC(InvalidValue, "Given hardware roi not possible");
if (roi != m_set_roi) {
m_hw_roi->setRoi(roi);
m_set_roi= roi;
_updateSize();
}
......
......@@ -653,6 +653,7 @@ void CtSaving::_SaveContainer::_open()
idx << pars.nextNumber;
std::string aFileName = pars.directory + DIR_SEPARATOR + pars.prefix + idx.str() + pars.suffix;
DEB_TRACE() << DEB_VAR1(aFileName);
if(pars.overwritePolicy == Abort &&
!access(aFileName.c_str(),R_OK))
......@@ -671,9 +672,14 @@ void CtSaving::_SaveContainer::_open()
for(int nbTry = 0;nbTry < 5;++nbTry)
{
m_fout.exceptions(std::ios_base::goodbit);
m_fout.open(aFileName.c_str(),openFlags);
m_fout.exceptions(std::ios_base::failbit | std::ios_base::badbit);
try {
m_fout.clear();
m_fout.exceptions(std::ios_base::failbit | std::ios_base::badbit);
m_fout.open(aFileName.c_str(),openFlags);
} catch (std::ios_base::failure &error) {
DEB_ERROR() << "Failure opening " << aFileName << ":"
<< error.what();
}
if(m_fout.fail())
{
......
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