Commit 3ecf37a8 authored by Rossa, Lutz's avatar Rossa, Lutz
Browse files

replace tabs with spaces

parent 22ce90b4
......@@ -99,22 +99,22 @@ BOOL APIENTRY DllMain(HANDLE /*hModule*/, DWORD ulReasonForCall, LPVOID /*lpRese
MODULE_API void InitializeModuleData()
{
LOG(("InitializeModuleData()\n"));
RegisterDevice(g_szCameraName, MM::CameraDevice, "Xeneth/Xenics camera");
RegisterDevice(g_szCameraName, MM::CameraDevice, "Xeneth/Xenics camera");
}
MODULE_API MM::Device* CreateDevice(const char* deviceName)
{
LOG(("CreateDevice(\"%s\")\n", deviceName));
if (!deviceName)
return 0;
return 0;
std::string deviceName_(deviceName);
if (deviceName_ == g_szCameraName)
{
XenethCamera* s = new XenethCamera();
std::string deviceName_(deviceName);
if (deviceName_ == g_szCameraName)
{
XenethCamera* s = new XenethCamera();
LOG(("CreateDevice(\"%s\") %p\n", deviceName, s));
return s;
}
}
LOG(("CreateDevice(\"%s\") nullptr\n", deviceName));
return 0;
......@@ -124,29 +124,29 @@ MODULE_API void DeleteDevice(MM::Device* pDevice)
{
LOG(("DeleteDevice(%p)\n", pDevice));
if (pDevice)
delete pDevice;
delete pDevice;
}
XenethCamera::XenethCamera() :
m_bInitialized(false),
m_bInitialized(false),
m_bInitializing(false),
m_byPixelSize(1),
m_byPixelSize(1),
m_szCameraPath("cam://default"),
m_lExposurePropertyIndex(-1),
m_uRoiX(0),
m_uRoiY(0),
m_uRoiW(0),
m_uRoiH(0)
m_lExposurePropertyIndex(-1),
m_uRoiX(0),
m_uRoiY(0),
m_uRoiW(0),
m_uRoiH(0)
{
LOG(("XenethCamera::XenethCamera(%p)\n", this));
g_hLogMutex.lock();
m_apInstances.push_back(this);
g_hLogMutex.unlock();
// create a property to select the camera
XenethCreateProperty("device path", m_szCameraPath.c_str(), MM::String, false, &XenethCamera::OnCameraPath, true);
// create a property to select the camera
XenethCreateProperty("device path", m_szCameraPath.c_str(), MM::String, false, &XenethCamera::OnCameraPath, true);
// create a property to select the calibration file name
XenethCreateProperty("calibration file", m_szCalibrationFile.c_str(), MM::String, false, &XenethCamera::OnCalibrationFile, true);
// create a property to select the calibration file name
XenethCreateProperty("calibration file", m_szCalibrationFile.c_str(), MM::String, false, &XenethCamera::OnCalibrationFile, true);
// create a property to select the calibration file name
XenethCreateProperty("log file", g_szLogFile.c_str(), MM::String, false, &XenethCamera::OnLogFile, true);
......@@ -155,55 +155,55 @@ XenethCamera::XenethCamera() :
XenethCreateProperty(g_szExposurePropName, std::to_string(m_lExposurePropertyIndex).c_str(),
MM::Integer, false, &XenethCamera::OnExposureProperty, true);
// register error message
SetErrorText(DEVICE_CAN_NOT_SET_AFTER_INITIALIZE, "cannot set property after Initialize before Shutdown");
SetErrorText(DEVICE_XENETH_INTERNAL, "Xeneth SDK internal error (I_DIRTY)");
SetErrorText(DEVICE_XENETH_UNKNOWN, "Xeneth SDK unknown error");
SetErrorText(DEVICE_XENETH_BUG, "Xeneth SDK generic error (E_BUG)");
SetErrorText(DEVICE_XENETH_NOINIT, "Xeneth SDK not successfully initialised (E_NOINIT)");
SetErrorText(DEVICE_XENETH_LOGICLOADFAILED, "Xeneth SDK invalid logic file (E_LOGICLOADFAILED)");
SetErrorText(DEVICE_XENETH_INTERFACE_ERROR, "Xeneth SDK command interface failure (E_INTERFACE_ERROR)");
SetErrorText(DEVICE_XENETH_OUT_OF_RANGE, "Xeneth SDK provided value is incapable of being produced by the hardware (E_OUT_OF_RANGE)");
SetErrorText(DEVICE_XENETH_NOT_SUPPORTED, "Xeneth SDK functionality not supported by this camera (E_NOT_SUPPORTED)");
SetErrorText(DEVICE_XENETH_NOT_FOUND, "Xeneth SDK file/data not found (E_NOT_FOUND)");
SetErrorText(DEVICE_XENETH_FILTER_DONE, "Xeneth SDK filter has finished processing, and will be removed (E_FILTER_DONE)");
SetErrorText(DEVICE_XENETH_NO_FRAME, "Xeneth SDK a frame was requested by calling GetFrame, but none was available (E_NO_FRAME)");
SetErrorText(DEVICE_XENETH_SAVE_ERROR, "Xeneth SDK couldn't save to file (E_SAVE_ERROR)");
SetErrorText(DEVICE_XENETH_MISMATCHED, "Xeneth SDK buffer size mismatch (E_MISMATCHED)");
SetErrorText(DEVICE_XENETH_BUSY, "Xeneth SDK the API can not read a temperature because the camera is busy (E_BUSY)");
SetErrorText(DEVICE_XENETH_INVALID_HANDLE, "Xeneth SDK an unknown handle was passed to the C API (E_INVALID_HANDLE)");
SetErrorText(DEVICE_XENETH_TIMEOUT, "Xeneth SDK operation timed out (E_TIMEOUT)");
SetErrorText(DEVICE_XENETH_FRAMEGRABBER, "Xeneth SDK frame grabber error (E_FRAMEGRABBER)");
SetErrorText(DEVICE_XENETH_NO_CONVERSION, "Xeneth SDK GetFrame could not convert the image data to the requested format (E_NO_CONVERSION)");
SetErrorText(DEVICE_XENETH_FILTER_SKIP_FRAME, "Xeneth SDK filter indicates the frame should be skipped (E_FILTER_SKIP_FRAME)");
SetErrorText(DEVICE_XENETH_WRONG_VERSION, "Xeneth SDK version mismatch (E_WRONG_VERSION)");
SetErrorText(DEVICE_XENETH_PACKET_ERROR, "Xeneth SDK the requested frame cannot be provided because at least one packet has been lost (E_PACKET_ERROR)");
SetErrorText(DEVICE_XENETH_WRONG_FORMAT, "Xeneth SDK the emissivity map you tried to set should be a 16 bit grayscale png (E_WRONG_FORMAT)");
SetErrorText(DEVICE_XENETH_WRONG_SIZE, "Xeneth SDK the emissivity map you tried to set has the wrong dimensions W/H (E_WRONG_SIZE)");
InitializeDefaultErrorMessages();
// register error message
SetErrorText(DEVICE_CAN_NOT_SET_AFTER_INITIALIZE, "cannot set property after Initialize before Shutdown");
SetErrorText(DEVICE_XENETH_INTERNAL, "Xeneth SDK internal error (I_DIRTY)");
SetErrorText(DEVICE_XENETH_UNKNOWN, "Xeneth SDK unknown error");
SetErrorText(DEVICE_XENETH_BUG, "Xeneth SDK generic error (E_BUG)");
SetErrorText(DEVICE_XENETH_NOINIT, "Xeneth SDK not successfully initialised (E_NOINIT)");
SetErrorText(DEVICE_XENETH_LOGICLOADFAILED, "Xeneth SDK invalid logic file (E_LOGICLOADFAILED)");
SetErrorText(DEVICE_XENETH_INTERFACE_ERROR, "Xeneth SDK command interface failure (E_INTERFACE_ERROR)");
SetErrorText(DEVICE_XENETH_OUT_OF_RANGE, "Xeneth SDK provided value is incapable of being produced by the hardware (E_OUT_OF_RANGE)");
SetErrorText(DEVICE_XENETH_NOT_SUPPORTED, "Xeneth SDK functionality not supported by this camera (E_NOT_SUPPORTED)");
SetErrorText(DEVICE_XENETH_NOT_FOUND, "Xeneth SDK file/data not found (E_NOT_FOUND)");
SetErrorText(DEVICE_XENETH_FILTER_DONE, "Xeneth SDK filter has finished processing, and will be removed (E_FILTER_DONE)");
SetErrorText(DEVICE_XENETH_NO_FRAME, "Xeneth SDK a frame was requested by calling GetFrame, but none was available (E_NO_FRAME)");
SetErrorText(DEVICE_XENETH_SAVE_ERROR, "Xeneth SDK couldn't save to file (E_SAVE_ERROR)");
SetErrorText(DEVICE_XENETH_MISMATCHED, "Xeneth SDK buffer size mismatch (E_MISMATCHED)");
SetErrorText(DEVICE_XENETH_BUSY, "Xeneth SDK the API can not read a temperature because the camera is busy (E_BUSY)");
SetErrorText(DEVICE_XENETH_INVALID_HANDLE, "Xeneth SDK an unknown handle was passed to the C API (E_INVALID_HANDLE)");
SetErrorText(DEVICE_XENETH_TIMEOUT, "Xeneth SDK operation timed out (E_TIMEOUT)");
SetErrorText(DEVICE_XENETH_FRAMEGRABBER, "Xeneth SDK frame grabber error (E_FRAMEGRABBER)");
SetErrorText(DEVICE_XENETH_NO_CONVERSION, "Xeneth SDK GetFrame could not convert the image data to the requested format (E_NO_CONVERSION)");
SetErrorText(DEVICE_XENETH_FILTER_SKIP_FRAME, "Xeneth SDK filter indicates the frame should be skipped (E_FILTER_SKIP_FRAME)");
SetErrorText(DEVICE_XENETH_WRONG_VERSION, "Xeneth SDK version mismatch (E_WRONG_VERSION)");
SetErrorText(DEVICE_XENETH_PACKET_ERROR, "Xeneth SDK the requested frame cannot be provided because at least one packet has been lost (E_PACKET_ERROR)");
SetErrorText(DEVICE_XENETH_WRONG_FORMAT, "Xeneth SDK the emissivity map you tried to set should be a 16 bit grayscale png (E_WRONG_FORMAT)");
SetErrorText(DEVICE_XENETH_WRONG_SIZE, "Xeneth SDK the emissivity map you tried to set has the wrong dimensions W/H (E_WRONG_SIZE)");
InitializeDefaultErrorMessages();
}
XenethCamera::~XenethCamera()
{
LOG(("XenethCamera::~XenethCamera(%p) m_bInitialized=%d\n", this, m_bInitialized));
if (m_bInitialized)
Shutdown();
Shutdown();
g_hLogMutex.lock();
m_apInstances.remove(this);
g_hLogMutex.unlock();
}
int XenethCamera::XenethCreateProperty(const char* szName, const char* szValue, MM::PropertyType eType,
bool bReadOnly, int(XenethCamera::* pFunction)(MM::PropertyBase* pProp, MM::ActionType eAct), bool bIsPreInitProperty)
bool bReadOnly, int(XenethCamera::* pFunction)(MM::PropertyBase* pProp, MM::ActionType eAct), bool bIsPreInitProperty)
{
CPropertyAction* pAction(nullptr);
if (pFunction)
{
pAction = new CPropertyAction(this, pFunction);
if (!pAction)
return DEVICE_OUT_OF_MEMORY;
}
int iResult(CreateProperty(szName, szValue, eType, bReadOnly, pAction, bIsPreInitProperty));
CPropertyAction* pAction(nullptr);
if (pFunction)
{
pAction = new CPropertyAction(this, pFunction);
if (!pAction)
return DEVICE_OUT_OF_MEMORY;
}
int iResult(CreateProperty(szName, szValue, eType, bReadOnly, pAction, bIsPreInitProperty));
if (iResult != DEVICE_OK && pAction)
{
delete pAction;
......@@ -216,54 +216,54 @@ int XenethCamera::XenethCreateProperty(const char* szName, const char* szValue,
int XenethCamera::Initialize()
{
int iResult(DEVICE_OK);
int iResult(DEVICE_OK);
LOG(("XenethCamera::Initialize(%p) m_bInitialized=%d\n", this, m_bInitialized));
if (m_bInitialized)
return DEVICE_OK;
// open camera and try to load calibration file
m_hCamera = XC_OpenCamera(m_szCameraPath.c_str());
if (!m_szCalibrationFile.empty())
{
iResult = ConvertXenethResult(XC_LoadCalibration(m_hCamera, m_szCalibrationFile.c_str(), XLC_StartSoftwareCorrection));
if (iResult != DEVICE_OK)
{
return DEVICE_OK;
// open camera and try to load calibration file
m_hCamera = XC_OpenCamera(m_szCameraPath.c_str());
if (!m_szCalibrationFile.empty())
{
iResult = ConvertXenethResult(XC_LoadCalibration(m_hCamera, m_szCalibrationFile.c_str(), XLC_StartSoftwareCorrection));
if (iResult != DEVICE_OK)
{
LOG(("XenethCamera::Initialize(%p) iResult=%d\n", this, iResult));
XC_CloseCamera(m_hCamera);
return iResult;
}
}
return iResult;
}
}
// force gray scale
XC_SetColourMode(m_hCamera, ColourMode_16);
// force gray scale
XC_SetColourMode(m_hCamera, ColourMode_16);
std::string szCameraIdentifier("unknown");
std::string szCameraSerial("unknown");
std::string szIntegrationTime;
std::string szCameraIdentifier("unknown");
std::string szCameraSerial("unknown");
std::string szIntegrationTime;
m_bInitializing = true;
int iPropertyCount(XC_GetPropertyCount(m_hCamera));
m_aProperties.clear();
m_aProperties.reserve(iPropertyCount);
for (int i = 0; i < iPropertyCount; ++i)
{
XenethProperty p;
ErrCode iError;
int iPropertyCount(XC_GetPropertyCount(m_hCamera));
m_aProperties.clear();
m_aProperties.reserve(iPropertyCount);
for (int i = 0; i < iPropertyCount; ++i)
{
XenethProperty p;
ErrCode iError;
#define XC_GET(name, arg2, onerr) \
p.m_sz##name.resize(65536); \
iError = XC_GetProperty##name(m_hCamera, arg2, &p.m_sz##name[0], static_cast<int>(p.m_sz##name.size())); \
if (iError == I_OK) { \
p.m_sz##name[p.m_sz##name.size() - 1] = '\0'; \
p.m_sz##name.resize(strlen(p.m_sz##name.c_str())); \
} else onerr;
XC_GET(Name, i, continue);
iError = XC_GetPropertyType(m_hCamera, p.m_szName.c_str(), &p.m_iType);
if (iError != I_OK)
continue; // ignore unsupported properties
XC_GET(Category, p.m_szName.c_str(), p.m_szCategory.clear());
XC_GET(Unit, p.m_szName.c_str(), p.m_szUnit.clear());
XC_GET(Range, p.m_szName.c_str(), p.m_szRange.clear());
p.m_sz##name.resize(65536); \
iError = XC_GetProperty##name(m_hCamera, arg2, &p.m_sz##name[0], static_cast<int>(p.m_sz##name.size())); \
if (iError == I_OK) { \
p.m_sz##name[p.m_sz##name.size() - 1] = '\0'; \
p.m_sz##name.resize(strlen(p.m_sz##name.c_str())); \
} else onerr;
XC_GET(Name, i, continue);
iError = XC_GetPropertyType(m_hCamera, p.m_szName.c_str(), &p.m_iType);
if (iError != I_OK)
continue; // ignore unsupported properties
XC_GET(Category, p.m_szName.c_str(), p.m_szCategory.clear());
XC_GET(Unit, p.m_szName.c_str(), p.m_szUnit.clear());
XC_GET(Range, p.m_szName.c_str(), p.m_szRange.clear());
if (!(p.m_iType & XType_Base_RW))
{
LOG(("XenethCamera::Initialize(%p) camera prop; name=\"%s\" type=%d cat=\"%s\" unit=\"%s\" range=\"%s\"\n",
......@@ -271,63 +271,63 @@ int XenethCamera::Initialize()
continue; // ignore unreadable properties
}
std::string szMMPropname("Xeneth ");
szMMPropname.append(p.m_szName);
XC_GET(Value, p.m_szName.c_str(), );
std::string szMMPropname("Xeneth ");
szMMPropname.append(p.m_szName);
XC_GET(Value, p.m_szName.c_str(), );
LOG(("XenethCamera::Initialize(%p) camera prop; name=\"%s\" type=%d val=\"%s\" cat=\"%s\" unit=\"%s\" range=\"%s\"\n",
this, p.m_szName.c_str(), p.m_iType, p.m_szValue.c_str(), p.m_szCategory.c_str(), p.m_szUnit.c_str(), p.m_szRange.c_str()));
MM::PropertyType eType(MM::String);
switch (p.m_iType & XType_Base_Mask)
{
case XType_Base_Number: // A number (floating)
eType = MM::Float;
break;
case XType_Base_Enum: // An enumerated type (a choice)
case XType_Base_Bool: // Boolean (true/false/1/0)
eType = MM::Integer;
break;
default:
break;
}
XenethCreateProperty(szMMPropname.c_str(), p.m_szValue.c_str(), eType,
!(p.m_iType & XType_Base_Writeable), &XenethCamera::OnCameraProperty, false);
std::string::size_type iIndex;
if ((p.m_iType & XType_Base_Mask) == XType_Base_Enum && !p.m_szRange.empty() &&
p.m_szRange.find(',') != std::string::npos)
{
// split enumeration "val1,val2,val3, ..."
std::string szRange(p.m_szRange);
long lValue(0);
szRange.append(",");
while (!szRange.empty())
{
iIndex = szRange.find(',');
if (iIndex == std::string::npos)
iIndex = szRange.size();
AddAllowedValue(p.m_szName.c_str(), szRange.substr(0, iIndex).c_str(), lValue++);
szRange.erase(0, iIndex + 1);
}
SetPropertyLimits(p.m_szName.c_str(), 0, lValue - 1);
}
else if ((p.m_iType & XType_Base_Mask) == XType_Base_Number && !p.m_szRange.empty() &&
(iIndex = p.m_szRange.find('>')) != std::string::npos)
{
// get range "min>max"
std::string szLeft(p.m_szRange.substr(0, iIndex));
std::string szRight(p.m_szRange.substr(iIndex + 1));
char* pEnd(const_cast<char*>(szLeft.c_str()));
double dMin(strtod(pEnd, &pEnd));
while (pEnd && *pEnd && std::isspace(*pEnd)) ++pEnd;
if (pEnd && !*pEnd)
{
pEnd = const_cast<char*>(szRight.c_str());
double dMax(strtod(pEnd, &pEnd));
while (pEnd && *pEnd && std::isspace(*pEnd)) ++pEnd;
if (pEnd && !*pEnd && dMin < dMax)
SetPropertyLimits(p.m_szName.c_str(), dMin, dMax);
}
}
MM::PropertyType eType(MM::String);
switch (p.m_iType & XType_Base_Mask)
{
case XType_Base_Number: // A number (floating)
eType = MM::Float;
break;
case XType_Base_Enum: // An enumerated type (a choice)
case XType_Base_Bool: // Boolean (true/false/1/0)
eType = MM::Integer;
break;
default:
break;
}
XenethCreateProperty(szMMPropname.c_str(), p.m_szValue.c_str(), eType,
!(p.m_iType & XType_Base_Writeable), &XenethCamera::OnCameraProperty, false);
std::string::size_type iIndex;
if ((p.m_iType & XType_Base_Mask) == XType_Base_Enum && !p.m_szRange.empty() &&
p.m_szRange.find(',') != std::string::npos)
{
// split enumeration "val1,val2,val3, ..."
std::string szRange(p.m_szRange);
long lValue(0);
szRange.append(",");
while (!szRange.empty())
{
iIndex = szRange.find(',');
if (iIndex == std::string::npos)
iIndex = szRange.size();
AddAllowedValue(p.m_szName.c_str(), szRange.substr(0, iIndex).c_str(), lValue++);
szRange.erase(0, iIndex + 1);
}
SetPropertyLimits(p.m_szName.c_str(), 0, lValue - 1);
}
else if ((p.m_iType & XType_Base_Mask) == XType_Base_Number && !p.m_szRange.empty() &&
(iIndex = p.m_szRange.find('>')) != std::string::npos)
{
// get range "min>max"
std::string szLeft(p.m_szRange.substr(0, iIndex));
std::string szRight(p.m_szRange.substr(iIndex + 1));
char* pEnd(const_cast<char*>(szLeft.c_str()));
double dMin(strtod(pEnd, &pEnd));
while (pEnd && *pEnd && std::isspace(*pEnd)) ++pEnd;
if (pEnd && !*pEnd)
{
pEnd = const_cast<char*>(szRight.c_str());
double dMax(strtod(pEnd, &pEnd));
while (pEnd && *pEnd && std::isspace(*pEnd)) ++pEnd;
if (pEnd && !*pEnd && dMin < dMax)
SetPropertyLimits(p.m_szName.c_str(), dMin, dMax);
}
}
#undef XC_GET
do
......@@ -349,24 +349,24 @@ int XenethCamera::Initialize()
szIntegrationTime = p.m_szName;
}
} while (0);
m_aProperties.push_back(p);
}
m_aProperties.push_back(p);
}
m_bInitialized = true;
m_bInitialized = true;
m_bInitializing = false;
CreateStringProperty(MM::g_Keyword_Name, "Xeneth Camera", true); // Name
CreateStringProperty(MM::g_Keyword_Description, "Xeneth/Xenics Camera", true); // Description
CreateStringProperty(MM::g_Keyword_CameraName, szCameraSerial.c_str(), true); // CameraName
CreateStringProperty(MM::g_Keyword_CameraID, szCameraIdentifier.c_str(), true); // CameraID
// binning
XenethCreateProperty(MM::g_Keyword_Binning, "1", MM::Integer, true, &XenethCamera::OnBinning, false);
SetPropertyLimits(MM::g_Keyword_Binning, 1, 1);
m_byPixelSize = static_cast<unsigned char>(XC_GetFrameSize(m_hCamera) / XC_GetWidth(m_hCamera) / XC_GetHeight(m_hCamera));
if (m_lExposurePropertyIndex < 0 || m_lExposurePropertyIndex >= static_cast<long>(m_aProperties.size()))
{
// property for exposure time
CreateStringProperty(MM::g_Keyword_Name, "Xeneth Camera", true); // Name
CreateStringProperty(MM::g_Keyword_Description, "Xeneth/Xenics Camera", true); // Description
CreateStringProperty(MM::g_Keyword_CameraName, szCameraSerial.c_str(), true); // CameraName
CreateStringProperty(MM::g_Keyword_CameraID, szCameraIdentifier.c_str(), true); // CameraID
// binning
XenethCreateProperty(MM::g_Keyword_Binning, "1", MM::Integer, true, &XenethCamera::OnBinning, false);
SetPropertyLimits(MM::g_Keyword_Binning, 1, 1);
m_byPixelSize = static_cast<unsigned char>(XC_GetFrameSize(m_hCamera) / XC_GetWidth(m_hCamera) / XC_GetHeight(m_hCamera));
if (m_lExposurePropertyIndex < 0 || m_lExposurePropertyIndex >= static_cast<long>(m_aProperties.size()))
{
// property for exposure time
m_lExposurePropertyIndex = -1;
if (m_aProperties.size() > 0)
{
......@@ -383,51 +383,51 @@ int XenethCamera::Initialize()
SetPropertyLimits(g_szExposurePropName, 0, static_cast<double>(m_aProperties.size() - 1));
}
SetProperty(g_szExposurePropName, std::to_string(m_lExposurePropertyIndex).c_str());
}
}
LOG(("XenethCamera::Initialize(%p) m_lExposurePropertyIndex=%d\n", this, static_cast<int>(m_lExposurePropertyIndex)));
ClearROI();
return DEVICE_OK;
return DEVICE_OK;
}
int XenethCamera::Shutdown()
{
LOG(("XenethCamera::Shutdown(%p) m_bInitialized=%d\n", this, m_bInitialized));
if (m_bInitialized)
{
{
if (XC_IsCapturing(m_hCamera))
{
int iResult(ConvertXenethResult(XC_StopCapture(m_hCamera)));
LOG(("XenethCamera::Shutdown(%p) stopped camera, iResult=%d\n", this, iResult));
}
XC_CloseCamera(m_hCamera);
m_bInitialized = false;
}
return DEVICE_OK;
m_bInitialized = false;
}
return DEVICE_OK;
}
void XenethCamera::GetName(char * name) const
{
CDeviceUtils::CopyLimitedString(name, g_szCameraName);
CDeviceUtils::CopyLimitedString(name, g_szCameraName);
}
long XenethCamera::GetImageBufferSize() const
{
return XC_GetFrameSize(m_hCamera);
return XC_GetFrameSize(m_hCamera);
}
unsigned XenethCamera::GetBitDepth() const
{
return XC_GetBitSize(m_hCamera);
return XC_GetBitSize(m_hCamera);
}
int XenethCamera::GetBinning() const
{
return 1;
return 1;
}
int XenethCamera::SetBinning(int)
{
return DEVICE_OK;
return DEVICE_OK;
}
void XenethCamera::SetExposure(double exposure)
......@@ -435,53 +435,53 @@ void XenethCamera::SetExposure(double exposure)
LOG(("XenethCamera::SetExposure(%p exposure=%g m_lExposurePropertyIndex=%d)\n",
this, exposure, static_cast<int>(m_lExposurePropertyIndex)));
if (std::isfinite(exposure) && m_lExposurePropertyIndex >= 0 &&
m_lExposurePropertyIndex < static_cast<long>(m_aProperties.size()))
{
XenethProperty* p(&m_aProperties[m_lExposurePropertyIndex]);
m_lExposurePropertyIndex < static_cast<long>(m_aProperties.size()))
{
XenethProperty* p(&m_aProperties[m_lExposurePropertyIndex]);
p->m_szValue = std::to_string(exposure);
switch (p->m_iType & XType_Base_Mask)
{
case XType_Base_Number:
{
switch (p->m_iType & XType_Base_Mask)
{
case XType_Base_Number:
{
double dMin(std::numeric_limits<double>::quiet_NaN()), dMax(dMin);
exposure = FromMilliseconds(exposure, p->m_szUnit.c_str());
if (XC_GetPropertyRangeF(m_hCamera, p->m_szName.c_str(), &dMin, &dMax) == I_OK &&
dMin < dMax)
{
if (XC_GetPropertyRangeF(m_hCamera, p->m_szName.c_str(), &dMin, &dMax) == I_OK &&
dMin < dMax)
{
if (exposure < dMin)
exposure = dMin;
else if (exposure > dMax)
exposure = dMax;
}
}
XC_SetPropertyValueF(m_hCamera, p->m_szName.c_str(), exposure, nullptr);
LOG(("XenethCamera::SetExposure(%p) exposure=%g\n", this, exposure));
break;
}
case XType_Base_Enum:
{
long lMin(std::numeric_limits<long>::max()), lMax(std::numeric_limits<long>::min());
if (XC_GetPropertyRangeL(m_hCamera, p->m_szName.c_str(), &lMin, &lMax) == I_OK &&
lMin < lMax)
{
if (exposure < lMin || exposure > lMax)
break;
}
XC_SetPropertyValueL(m_hCamera, p->m_szName.c_str(), static_cast<long>(exposure), nullptr);
break;
}
default:
XC_SetPropertyValue(m_hCamera, p->m_szName.c_str(), p->m_szValue.c_str(), nullptr);
break;
}
}
}
case XType_Base_Enum:
{
long lMin(std::numeric_limits<long>::max()), lMax(std::numeric_limits<long>::min());
if (XC_GetPropertyRangeL(m_hCamera, p->m_szName.c_str(), &lMin, &lMax) == I_OK &&
lMin < lMax)
{
if (exposure < lMin || exposure > lMax)
break;
}
XC_SetPropertyValueL(m_hCamera, p->m_szName.c_str(), static_cast<long>(exposure), nullptr);
break;
}
default:
XC_SetPropertyValue(m_hCamera, p->m_szName.c_str(), p->m_szValue.c_str(), nullptr);
break;
}
}
}
double XenethCamera::GetExposure() const
{
if (m_lExposurePropertyIndex >= 0 &&
m_lExposurePropertyIndex < static_cast<long>(m_aProperties.size()))
{
XenethProperty* p(const_cast<XenethProperty*>(&m_aProperties[m_lExposurePropertyIndex]));
if (m_lExposurePropertyIndex >= 0 &&
m_lExposurePropertyIndex < static_cast<long>(m_aProperties.size()))
{
XenethProperty* p(const_cast<XenethProperty*>(&m_aProperties[m_lExposurePropertyIndex]));
switch (p->m_iType & XType_Base_Mask)
{
case XType_Base_Number:
......@@ -519,8 +519,8 @@ double XenethCamera::GetExposure() const
}
}
char* pEnd(const_cast<char*>(p->m_szValue.c_str()));
double dValue(strtod(pEnd, &pEnd));
char* pEnd(const_cast<char*>(p->m_szValue.c_str()));
double dValue(strtod(pEnd, &pEnd));
LOG(("XenethCamera::GetExposure(%p) value=\"%s\" unit=\"%s\" dValue=%g\n",
this, p->m_szValue.c_str(), p->m_szUnit.c_str(), dValue));
if (pEnd && pEnd > p->m_szValue.c_str())
......@@ -530,7 +530,7 @@ double XenethCamera::GetExposure() const
this, static_cast<int>(m_lExposurePropertyIndex), dValue));
return dValue;
}
}
}
LOG(("XenethCamera::GetExposure(%p) m_lExposurePropertyIndex=%d -> NaN\n",
this, static_cast<int>(m_lExposurePropertyIndex)));
return std::numeric_limits<double>::quiet_NaN();
......@@ -538,8 +538,8 @@ double XenethCamera::GetExposure() const
int XenethCamera::SetROI(unsigned uX, unsigned uY, unsigned uWidth, unsigned uHeight)
{
dword dwCamWidth (XC_GetWidth (m_hCamera));
dword dwCamHeight(XC_GetHeight(m_hCamera));
dword dwCamWidth (XC_GetWidth (m_hCamera));
dword dwCamHeight(XC_GetHeight(m_hCamera));
LOG(("XenethCamera::SetROI(%p x=%u y=%u w=%u h=%u) cam=%ux%u\n", this, uX, uY, uWidth, uHeight, dwCamWidth, dwCamHeight));
if (!dwCamWidth || dwCamWidth > 0x0FFFFFFUL ||
!dwCamHeight || dwCamHeight > 0x0FFFFFFUL)
......@@ -548,12 +548,12 @@ int XenethCamera::SetROI(unsigned uX, unsigned uY, unsigned uWidth, unsigned uHe