Commit b52848bf authored by Andreas Persson's avatar Andreas Persson

SyncCtrlOb: implement latency control

Add debug macros to member functions
parent ad35d634
......@@ -92,10 +92,6 @@ public:
void setExpTime(double exp_time);
void getExpTimeRange(double& min_exp_time, double& max_exp_time);
void getLatTime(double& lat_time);
void setLatTime(double lat_time);
void getLatTimeRange(double& min_lat_time, double& max_lat_time) const;
void getNbFrames(int& nb_frames);
void setNbFrames(int nb_frames);
void getNbHwAcquiredFrames(int &nb_acq_frames);
......
......@@ -60,7 +60,13 @@ public:
virtual void getValidRanges(ValidRangesType& valid_ranges);
private:
Camera& m_cam;
void _adjustFrameRate();
Camera& m_cam;
double m_exp_time;
double m_lat_time;
double m_max_acq_period;
ValidRangesType m_valid_ranges;
};
} // namespace PointGrey
......
......@@ -35,10 +35,6 @@ namespace PointGrey
void setExpTime(double exp_time);
void getExpTimeRange(double& min_exp_time /Out/, double& max_exp_time /Out/);
void getLatTime(double& lat_time /Out/);
void setLatTime(double lat_time);
void getLatTimeRange(double& min_lat_time /Out/, double& max_lat_time /Out/) const;
void getNbFrames(int& nb_frames /Out/);
void setNbFrames(int nb_frames);
......
......@@ -77,9 +77,6 @@ Camera::Camera(const int camera_serial,
m_image_settings.pixelFormat = FlyCapture2::PIXEL_FORMAT_MONO8;
_applyImageSettings();
// Set auto frame rate
setAutoFrameRate(true);
//Acquisition Thread
m_acq_thread = new _AcqThread(*this);
......@@ -431,38 +428,6 @@ void Camera::setTrigMode(TrigMode mode)
THROW_HW_ERROR(Error) << "Unable to set trigger mode settings: " << m_error.GetDescription();
}
//-----------------------------------------------------
//
//-----------------------------------------------------
void Camera::getLatTime(double& lat_time)
{
// latency is not managed
DEB_MEMBER_FUNCT();
lat_time = 0;
DEB_RETURN() << DEB_VAR1(lat_time);
}
//-----------------------------------------------------
//
//-----------------------------------------------------
void Camera::setLatTime(double lat_time)
{
// latency is not managed
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(lat_time);
}
//-----------------------------------------------------
//
//-----------------------------------------------------
void Camera::getLatTimeRange(double& min_lat_time, double& max_lat_time) const
{
DEB_MEMBER_FUNCT();
min_lat_time = 0;
max_lat_time = 0;
DEB_RETURN() << DEB_VAR2(min_lat_time, max_lat_time);
}
//-----------------------------------------------------
//
//-----------------------------------------------------
......
......@@ -34,6 +34,22 @@ SyncCtrlObj::SyncCtrlObj(Camera& cam)
: m_cam(cam)
{
DEB_CONSTRUCTOR();
double exp_time_ms, min_exp_time_ms, max_exp_time_ms;
double min_frame_rate, max_frame_rate;
m_cam.setAutoFrameRate(true);
m_cam.getExpTime(exp_time_ms);
m_cam.getExpTimeRange(min_exp_time_ms, max_exp_time_ms);
m_cam.getFrameRateRange(min_frame_rate, max_frame_rate);
m_exp_time = exp_time_ms * 1E-3;
m_lat_time = 0;
m_max_acq_period = 1.0 / min_frame_rate;
m_valid_ranges.min_exp_time = min_exp_time_ms * 1E-3;
m_valid_ranges.max_exp_time = m_max_acq_period;
m_valid_ranges.min_lat_time = 0;
m_valid_ranges.max_lat_time = m_max_acq_period - m_exp_time;
}
//-----------------------------------------------------
......@@ -51,6 +67,7 @@ bool SyncCtrlObj::checkTrigMode(TrigMode trig_mode)
void SyncCtrlObj::setTrigMode(TrigMode trig_mode)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(trig_mode);
if (!checkTrigMode(trig_mode))
THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(trig_mode);
m_cam.setTrigMode(trig_mode);
......@@ -61,7 +78,9 @@ void SyncCtrlObj::setTrigMode(TrigMode trig_mode)
//-----------------------------------------------------
void SyncCtrlObj::getTrigMode(TrigMode& trig_mode)
{
DEB_MEMBER_FUNCT();
m_cam.getTrigMode(trig_mode);
DEB_RETURN() << DEB_VAR1(trig_mode);
}
//-----------------------------------------------------
......@@ -69,8 +88,14 @@ void SyncCtrlObj::getTrigMode(TrigMode& trig_mode)
//-----------------------------------------------------
void SyncCtrlObj::setExpTime(double exp_time)
{
double exp_time_ms = 1E3 * exp_time;
m_cam.setExpTime(exp_time_ms);
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(exp_time);
m_exp_time = exp_time;
_adjustFrameRate();
m_cam.setExpTime(exp_time * 1E3);
m_valid_ranges.max_lat_time = m_max_acq_period - m_exp_time;
validRangesChanged(m_valid_ranges);
}
//-----------------------------------------------------
......@@ -78,9 +103,9 @@ void SyncCtrlObj::setExpTime(double exp_time)
//-----------------------------------------------------
void SyncCtrlObj::getExpTime(double& exp_time)
{
double exp_time_ms;
m_cam.getExpTime(exp_time_ms);
exp_time = exp_time_ms * 1E-3;
DEB_MEMBER_FUNCT();
exp_time = m_exp_time;
DEB_RETURN() << DEB_VAR1(exp_time);
}
//-----------------------------------------------------
......@@ -88,7 +113,13 @@ void SyncCtrlObj::getExpTime(double& exp_time)
//-----------------------------------------------------
void SyncCtrlObj::setLatTime(double lat_time)
{
m_cam.setLatTime(lat_time);
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(lat_time);
m_lat_time = lat_time;
_adjustFrameRate();
m_valid_ranges.max_exp_time = m_max_acq_period - m_lat_time;
validRangesChanged(m_valid_ranges);
}
//-----------------------------------------------------
......@@ -96,7 +127,9 @@ void SyncCtrlObj::setLatTime(double lat_time)
//-----------------------------------------------------
void SyncCtrlObj::getLatTime(double& lat_time)
{
m_cam.getLatTime(lat_time);
DEB_MEMBER_FUNCT();
lat_time = m_lat_time;
DEB_RETURN() << DEB_VAR1(lat_time);
}
//-----------------------------------------------------
......@@ -104,6 +137,8 @@ void SyncCtrlObj::getLatTime(double& lat_time)
//-----------------------------------------------------
void SyncCtrlObj::setNbHwFrames(int nb_frames)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(nb_frames);
m_cam.setNbFrames(nb_frames);
}
......@@ -112,7 +147,9 @@ void SyncCtrlObj::setNbHwFrames(int nb_frames)
//-----------------------------------------------------
void SyncCtrlObj::getNbHwFrames(int& nb_frames)
{
DEB_MEMBER_FUNCT();
m_cam.getNbFrames(nb_frames);
DEB_RETURN() << DEB_VAR1(nb_frames);
}
//-----------------------------------------------------
......@@ -121,14 +158,21 @@ void SyncCtrlObj::getNbHwFrames(int& nb_frames)
void SyncCtrlObj::getValidRanges(ValidRangesType& valid_ranges)
{
DEB_MEMBER_FUNCT();
double min_time_ms;
double max_time_ms;
m_cam.getExpTimeRange(min_time_ms, max_time_ms);
valid_ranges.min_exp_time = min_time_ms * 1E-3;
valid_ranges.max_exp_time = max_time_ms * 1E-3;
valid_ranges = m_valid_ranges;
DEB_RETURN() << DEB_VAR1(valid_ranges);
}
m_cam.getLatTimeRange(min_time_ms, max_time_ms);
valid_ranges.min_lat_time = min_time_ms * 1E-3;
valid_ranges.max_lat_time = max_time_ms * 1E-3;
//-----------------------------------------------------
//
//-----------------------------------------------------
void SyncCtrlObj::_adjustFrameRate()
{
DEB_MEMBER_FUNCT();
if (m_lat_time > 1E-6)
{
double period = m_exp_time + m_lat_time;
m_cam.setFrameRate(1.0 / period);
}
else
m_cam.setAutoFrameRate(true);
}
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