Skip to content
Snippets Groups Projects
Commit bef62ad3 authored by Laurent Claustre's avatar Laurent Claustre
Browse files

Merge branch '7-wrong-param-used-to-get-max-allowed-gain-value' into 'master'

Fixed wrong min/max gain.

Closes #7

See merge request !16
parents ce42eb41 6a0c909b
No related branches found
No related tags found
1 merge request!16Fixed wrong min/max gain.
Pipeline #98716 passed
......@@ -17,7 +17,13 @@ cam_ip_address Yes N/A The camera's ip or hostname
Attributes
----------
This device has no attribute.
============================== ======= ======================= ============================================================
Attribute name RW Type Description
============================== ======= ======================= ============================================================
gain rw DevFloat normalized video gain, value between 0 (=pvmin), no gain, and 1 (=pvmax)
pv_gain_range ro DevULong[pvmin, pvmax] min and max allowed values of the PvApi gain
pv_gain rw DevULong video gain, value in the interval [pvmin, pvmax]
============================== ======= ======================= ============================================================
Commands
--------
......
......@@ -37,7 +37,7 @@ namespace lima
void getGain(double&) const;
void setPvGain(unsigned long);
void getPvGain(unsigned long&) const;
void getGainAutoMax(unsigned long&) const;
void getPvGainRange(unsigned long&, unsigned long&) const;
void getCameraName(std::string& name);
......@@ -57,7 +57,8 @@ namespace lima
char m_sensor_type[64];
tPvUint32 m_ufirmware_maj, m_ufirmware_min;
tPvUint32 m_maxwidth, m_maxheight;
tPvUint32 m_gainautomax;
tPvUint32 m_maxgain;
tPvUint32 m_mingain;
tPvUint32 m_uid;
tPvFrame m_frame[2];
Bin m_bin;
......
......@@ -20,7 +20,7 @@ namespace Prosilica
void getGain(double& /Out/) const;
void setPvGain(unsigned long);
void getPvGain(unsigned long& /Out/) const;
void getGainAutoMax(unsigned long& /Out/) const;
void getPvGainRange(unsigned long& /Out/, unsigned long& /Out/) const;
VideoMode getVideoMode() const;
void setVideoMode(VideoMode);
......
......@@ -73,9 +73,9 @@ Camera::Camera(const std::string& ip_addr,bool master,
if(error)
throw LIMA_HW_EXC(Error,"Can't set image height");
PvAttrUint32Get(m_handle, "GainAutoMax", &m_gainautomax);
PvAttrRangeUint32(m_handle, "GainValue", &m_mingain, &m_maxgain);
DEB_TRACE() << DEB_VAR1(m_gainautomax);
DEB_TRACE() << DEB_VAR2(m_mingain, m_maxgain);
VideoMode localVideoMode;
if(isMonochrome())
......@@ -368,7 +368,7 @@ void Camera::getBin(Bin &hw_bin)
//-----------------------------------------------------
void Camera::setGain(double aGain)
{
tPvUint32 localGain = tPvUint32(aGain * m_gainautomax);
tPvUint32 localGain = tPvUint32(m_mingain + aGain * (m_maxgain - m_mingain));
tPvErr error=PvAttrUint32Set(m_handle, "GainValue", localGain);
if(error)
throw LIMA_HW_EXC(Error,"Can't set gain to asked value");
......@@ -381,7 +381,7 @@ void Camera::getGain(double &aGain) const
{
tPvUint32 localGain;
tPvErr error=PvAttrUint32Get(m_handle, "GainValue", &localGain);
aGain = double(localGain) / m_gainautomax;
aGain = double(localGain - m_mingain) / (m_maxgain - m_mingain);
}
//-----------------------------------------------------
......@@ -405,9 +405,10 @@ void Camera::getPvGain(unsigned long &pvGain) const
//-----------------------------------------------------
// @brief return the max auto gain value (PvApi gain value)
//-----------------------------------------------------
void Camera::getGainAutoMax(unsigned long &gainAutoMax) const
void Camera::getPvGainRange(unsigned long &minGain, unsigned long &maxGain) const
{
gainAutoMax = m_gainautomax;
minGain = m_mingain;
maxGain = m_maxgain;
}
// //-----------------------------------------------------
......
......@@ -97,14 +97,15 @@ class ProsilicaClass(PyTango.DeviceClass):
}
attr_list = {
'gain_auto_max':
'pv_gain_range':
[[PyTango.DevULong,
PyTango.SCALAR,
PyTango.READ],
PyTango.SPECTRUM,
PyTango.READ,
2],
{
'unit': 'N/A',
'format': '',
'description': 'camera max auto gain',
'description': 'camera min/max gain value (PvApi)',
}],
'gain':
[[PyTango.DevFloat,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment