Commit 2d3b8e5d authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

* Optimised the way Frelon::Model feature retrieving

  by using cache variables and static Firmware const objects
* Implemented (Stripe)Concatenation acq. mode in FrelonAcq,
  allow retrieval of multiple concatenated frames in readFrames
parent a7098b15
......@@ -49,6 +49,9 @@ class Firmware
int getMinor() const;
std::string getRelease() const;
static const Firmware v2_1b;
static const Firmware v3_0i;
private:
void checkValid();
......@@ -107,7 +110,7 @@ class Model
~Model();
void setVersionStr(const std::string& ver);
Firmware& getFirmware();
const Firmware& getFirmware();
void setComplexSerialNb(int complex_ser_nb);
void getComplexSerialNb(int& complex_ser_nb);
......@@ -130,11 +133,18 @@ class Model
std::string getName();
private:
void update();
void checkValid();
int getSerialNbParam(SerNbParam param);
Firmware m_firmware;
int m_complex_ser_nb;
bool m_valid;
ChipType m_chip_type;
bool m_modes_avail;
bool m_time_calc;
bool m_good_htd;
};
......
......@@ -257,7 +257,18 @@ class FrelonAcq:
fdim = self.m_ct_image.getImageDim()
deb.Return('Frame dim: %s' % fdim)
return fdim
@DEB_MEMBER_FUNCT
def setAcqMode(self, acq_mode):
deb.Param('Setting acq. mode: %s' % acq_mode)
self.m_ct_acq.setAcqMode(acq_mode)
@DEB_MEMBER_FUNCT
def getAcqMode(self):
acq_mode = self.m_ct_acq.getAcqMode()
deb.Return('Getting acq. mode: %s' % acq_mode)
return acq_mode
@DEB_MEMBER_FUNCT
def setFlip(self, flip):
deb.Param('Setting flip mode: %s' % flip)
......@@ -407,6 +418,33 @@ class FrelonAcq:
nb_frames = self.m_ct_acq.getAcqNbFrames()
deb.Return('Getting nb. frames: %s' % nb_frames)
return nb_frames
@DEB_MEMBER_FUNCT
def setStripeConcat(self, stripe_concat):
deb.Param('Setting stripe concat.: %s' % stripe_concat)
if stripe_concat:
acq_mode = Concatenation
else:
acq_mode = Single
self.setAcqMode(acq_mode)
@DEB_MEMBER_FUNCT
def getStripeConcat(self):
acq_mode = self.getAcqMode()
stripe_concat = (acq_mode == Concatenation)
deb.Return('Getting stripe concat.: %s' % stripe_concat)
return stripe_concat
@DEB_MEMBER_FUNCT
def setNbConcatFrames(self, concat_frames):
deb.Param('Setting nb. concat. frames: %s' % concat_frames)
self.m_ct_acq.setConcatNbFrames(concat_frames)
@DEB_MEMBER_FUNCT
def getNbConcatFrames(self):
concat_frames = self.m_ct_acq.getConcatNbFrames()
deb.Return('Getting nb. concat. frames: %s' % concat_frames)
return concat_frames
@DEB_MEMBER_FUNCT
def setExpTime(self, exp_time):
......@@ -429,7 +467,7 @@ class FrelonAcq:
spb2_config = self.m_cam.getSPB2Config()
deb.Param('Getting SPB2 config: %s' % spb2_config)
return spb2_config
@DEB_MEMBER_FUNCT
def setFilePar(self, file_par):
deb.Param('Setting file par: %s' % file_par)
......@@ -502,11 +540,11 @@ class FrelonAcq:
self.m_ct.stopAcq()
@DEB_MEMBER_FUNCT
def readFrame(self, frame_nb):
img_data = self.m_ct.ReadImage(frame_nb)
def readFrames(self, frame_nb, read_block_len=1):
img_data = self.m_ct.ReadImage(frame_nb, read_block_len)
data = img_data.buffer
s = data.tostring()
deb.Return('Getting frame #%s: %s bytes' % (frame_nb, len(s)))
deb.Return('Getting frame(s) #%s: %s bytes' % (frame_nb, len(s)))
return s
@DEB_MEMBER_FUNCT
......
......@@ -44,6 +44,8 @@ class Firmware
int getMinor() const;
std::string getRelease() const;
static const Frelon::Firmware v2_1b;
static const Frelon::Firmware v3_0i;
};
......@@ -59,7 +61,7 @@ class Model
~Model();
void setVersionStr(const std::string& ver);
Frelon::Firmware& getFirmware();
const Frelon::Firmware& getFirmware();
void setComplexSerialNb(int complex_ser_nb);
void getComplexSerialNb(int& complex_ser_nb /Out/);
......
......@@ -26,6 +26,9 @@ using namespace lima;
using namespace lima::Frelon;
using namespace std;
const Firmware Firmware::v2_1b("2.1b");
const Firmware Firmware::v3_0i("3.0i");
Firmware::Firmware()
{
DEB_CONSTRUCTOR();
......@@ -108,22 +111,16 @@ bool Firmware::isValid() const
int Firmware::getMajor() const
{
DEB_MEMBER_FUNCT();
DEB_RETURN() << DEB_VAR1(m_major);
return m_major;
}
int Firmware::getMinor() const
{
DEB_MEMBER_FUNCT();
DEB_RETURN() << DEB_VAR1(m_minor);
return m_minor;
}
string Firmware::getRelease() const
{
DEB_MEMBER_FUNCT();
DEB_RETURN() << DEB_VAR1(m_rel);
return m_rel;
}
......@@ -152,10 +149,13 @@ void Model::setVersionStr(const std::string& ver)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(ver);
m_valid = false;
m_firmware.setVersionStr(ver);
update();
}
Firmware& Model::getFirmware()
const Firmware& Model::getFirmware()
{
return m_firmware;
}
......@@ -164,7 +164,9 @@ void Model::setComplexSerialNb(int complex_ser_nb)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(complex_ser_nb);
m_complex_ser_nb = complex_ser_nb;
update();
}
void Model::getComplexSerialNb(int& complex_ser_nb)
......@@ -180,22 +182,46 @@ void Model::reset()
m_firmware.reset();
m_complex_ser_nb = 0;
update();
}
bool Model::isValid()
void Model::update()
{
DEB_MEMBER_FUNCT();
bool valid = (m_complex_ser_nb > 0) && m_firmware.isValid();
DEB_RETURN() << DEB_VAR1(valid);
return valid;
m_valid = (m_complex_ser_nb > 0) && m_firmware.isValid();
DEB_TRACE() << DEB_VAR1(m_valid);
if (!m_valid)
return;
bool is_spb2 = isSPB2();
if (is_spb2)
m_chip_type = ChipType(getSerialNbParam(SPB2Type) >> 12);
else
m_chip_type = bool(getSerialNbParam(SPB1Kodak)) ? Kodak : Atmel;
bool firm_v2_1b = (is_spb2 && (m_firmware >= Firmware::v2_1b));
m_modes_avail = m_time_calc = firm_v2_1b;
bool firm_v3_0i = (is_spb2 && (m_firmware >= Firmware::v3_0i));
m_good_htd = firm_v3_0i;
DEB_TRACE() << DEB_VAR4(m_chip_type, m_modes_avail, m_time_calc,
m_good_htd);
}
bool Model::isValid()
{
DEB_MEMBER_FUNCT();
DEB_RETURN() << DEB_VAR1(m_valid);
return m_valid;
}
void Model::checkValid()
{
DEB_MEMBER_FUNCT();
if (!isValid())
if (!m_valid)
THROW_HW_ERROR(InvalidValue)
<< "Frelon model not fully initialised yet";
}
......@@ -256,13 +282,10 @@ ChipType Model::getChipType()
{
DEB_MEMBER_FUNCT();
ChipType chip_type;
if (isSPB1())
chip_type = bool(getSerialNbParam(SPB1Kodak)) ? Kodak : Atmel;
else
chip_type = ChipType(getSerialNbParam(SPB2Type) >> 12);
DEB_RETURN() << DEB_VAR1(chip_type);
return chip_type;
checkValid();
DEB_RETURN() << DEB_VAR1(m_chip_type);
return m_chip_type;
}
bool Model::hasTaper()
......@@ -278,27 +301,30 @@ bool Model::hasModesAvail()
{
DEB_MEMBER_FUNCT();
bool avail_modes = (isSPB2() && (m_firmware >= Firmware("2.1b")));
DEB_RETURN() << DEB_VAR1(avail_modes);
return avail_modes;
checkValid();
DEB_RETURN() << DEB_VAR1(m_modes_avail);
return m_modes_avail;
}
bool Model::hasTimeCalc()
{
DEB_MEMBER_FUNCT();
bool time_calc = (isSPB2() && (m_firmware >= Firmware("2.1b")));
DEB_RETURN() << DEB_VAR1(time_calc);
return time_calc;
checkValid();
DEB_RETURN() << DEB_VAR1(m_time_calc);
return m_time_calc;
}
bool Model::hasGoodHTD()
{
DEB_MEMBER_FUNCT();
bool good_htd = (isSPB2() && (m_firmware >= Firmware("3.0i")));
DEB_RETURN() << DEB_VAR1(good_htd);
return good_htd;
checkValid();
DEB_RETURN() << DEB_VAR1(m_good_htd);
return m_good_htd;
}
double Model::getPixelSize()
......
Supports Markdown
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