Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acquisition mode fallback #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 73 additions & 34 deletions GenICamApp/src/GenICamFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int GenICamFeature::setParam (bool value)
return (int) mSet->getPortDriver()->setIntegerParam(mAsynIndex, (int) value);
}

GenICamFeature::GenICamFeature (GenICamFeatureSet *set,
GenICamFeature::GenICamFeature (GenICamFeatureSet *set,
string const & asynName, asynParamType asynType, int asynIndex,
string const &featureName, GCFeatureType_t featureType)
: mAsynName(asynName), mAsynType(asynType), mAsynIndex(asynIndex),
Expand Down Expand Up @@ -207,7 +207,7 @@ int GenICamFeature::write(void *pValue, void *pReadbackValue, bool bSetParam)
epicsInt64 value;
if (pValue)
value = *(epicsInt64*)pValue;
else
else
getParam(value);
// Check against the min and max
epicsInt64 max = readIntegerMax();
Expand Down Expand Up @@ -238,7 +238,7 @@ int GenICamFeature::write(void *pValue, void *pReadbackValue, bool bSetParam)
}
case GCFeatureTypeBoolean: {
epicsInt32 value;
if (pValue)
if (pValue)
value = *(epicsInt32*)pValue;
else
getParam(value);
Expand All @@ -255,7 +255,7 @@ int GenICamFeature::write(void *pValue, void *pReadbackValue, bool bSetParam)
}
case GCFeatureTypeDouble: {
epicsFloat64 value;
if (pValue)
if (pValue)
value = *(epicsFloat64*)pValue;
else
getParam(value);
Expand Down Expand Up @@ -286,7 +286,7 @@ int GenICamFeature::write(void *pValue, void *pReadbackValue, bool bSetParam)
}
case GCFeatureTypeEnum: {
epicsInt32 value;
if (pValue)
if (pValue)
value = *(epicsInt32*)pValue;
else
getParam(value);
Expand All @@ -304,7 +304,7 @@ int GenICamFeature::write(void *pValue, void *pReadbackValue, bool bSetParam)
}
case GCFeatureTypeString: {
const char *value;
if (pValue)
if (pValue)
value = (const char*)pValue;
else {
std::string temp;
Expand Down Expand Up @@ -357,7 +357,7 @@ int GenICamFeature::read(void *pValue, bool bSetParam)
enumStrings[0] = (char *)"N.A.";
enumValues[0] = 0;
enumSeverities[0] = 0;
mSet->getPortDriver()->doCallbacksEnum(enumStrings, enumValues, enumSeverities,
mSet->getPortDriver()->doCallbacksEnum(enumStrings, enumValues, enumSeverities,
1, mAsynIndex, 0);
}
return EXIT_SUCCESS;
Expand Down Expand Up @@ -428,7 +428,7 @@ int GenICamFeature::read(void *pValue, bool bSetParam)
enumValues[i] = mEnumValues[i];
enumSeverities[i] = 0;
}
mSet->getPortDriver()->doCallbacksEnum(enumStrings, enumValues, enumSeverities,
mSet->getPortDriver()->doCallbacksEnum(enumStrings, enumValues, enumSeverities,
numEnums, mAsynIndex, 0);
delete [] enumStrings; delete [] enumValues; delete [] enumSeverities;
}
Expand Down Expand Up @@ -460,7 +460,7 @@ std::string GenICamFeature::getValueAsString()
// static const char *functionName = "GenICamFeature::getValueAsString";
std::string valueString = "Not available";
char buff[100];

if (isImplemented() && isReadable()) {
switch (mFeatureType) {
case GCFeatureTypeString: {
Expand All @@ -471,9 +471,9 @@ std::string GenICamFeature::getValueAsString()
epicsInt64 temp = readInteger();
sprintf(buff, "%lld", temp);
valueString = buff;
break;
break;
}

case GCFeatureTypeDouble: {
double temp = readDouble();
sprintf(buff, "%f", temp);
Expand All @@ -495,7 +495,7 @@ std::string GenICamFeature::getValueAsString()
break;
}
default:
break;
break;
}
}
return valueString;
Expand All @@ -513,7 +513,7 @@ double GenICamFeature::convertDoubleUnits(double inputValue, GCConvertDirection_
outputValue = inputValue / 1.e6;
else
outputValue = inputValue * 1.e6;
}
}
else if (mAsynName == "ACQ_PERIOD") {
// EPICS uses period in seconds, GenICam uses rate in Hz
outputValue = 1. / inputValue;
Expand All @@ -524,38 +524,77 @@ double GenICamFeature::convertDoubleUnits(double inputValue, GCConvertDirection_
int GenICamFeature::convertEnum(epicsInt32 inputValue, GCConvertDirection_t direction)
{
epicsInt32 outputValue = inputValue;
if (mAsynName == "IMAGE_MODE") {
if (mAsynName == "IMAGE_MODE")
{
// We want to use the EPICS enums
// Cannot use switch because the things we are testing are not constants
if (direction == GCConvertToEPICS) {
if (inputValue == mSet->mAcquisitionModeSingleFrame) {
outputValue = ADImageSingle;
}
else if (inputValue == mSet->mAcquisitionModeMultiFrame) {
outputValue = ADImageMultiple;
if (direction == GCConvertToEPICS)
{
// prefer single, fall back to multiple and finally continuous
if (inputValue == mSet->mAcquisitionModeSingleFrame)
{
if (mSet->mAcquisitionModeSingleFrame != -1)
{
outputValue = ADImageSingle;
}
else if (mSet->mAcquisitionModeMultiFrame != 1)
{
outputValue = ADImageMultiple;
}
else
{
outputValue = ADImageContinuous;
}
}
else if (inputValue == mSet->mAcquisitionModeContinuous) {
outputValue = ADImageContinuous;
// prefer multiple, fall back to continuous
else if (inputValue == mSet->mAcquisitionModeMultiFrame)
{
if (mSet->mAcquisitionModeMultiFrame != -1)
{
outputValue = ADImageMultiple;
}
else
{
outputValue = ADImageContinuous;
}
}
// If MultiFrame is not supported then we can't use readback.
// Use the value that was last stored when converting from EPICS
if (mSet->mAcquisitionModeMultiFrame == -1) {
outputValue = mImageMode;
// inputValue == mSet->mAcquisitionModeContinuous or something wrong with mode values
else
{
outputValue = ADImageContinuous;
}
} else {
switch (inputValue) {
case ADImageSingle:
outputValue = mSet->mAcquisitionModeSingleFrame;
}
else
{
switch (inputValue)
{
// Some cameras (TIS DMK 33GX174) don't support Single- or MultiFrame
case ADImageSingle:
if (mSet->mAcquisitionModeSingleFrame != -1)
{
outputValue = mSet->mAcquisitionModeSingleFrame;
}
else if (mSet->mAcquisitionModeMultiFrame != -1)
{
outputValue = mSet->mAcquisitionModeMultiFrame;
}
else
{
outputValue = mSet->mAcquisitionModeContinuous;
}
break;
case ADImageMultiple:
case ADImageMultiple:
// Some cameras, e.g. JAI don't support MultiFrame so we convert to Continuous
if (mSet->mAcquisitionModeMultiFrame != -1) {
if (mSet->mAcquisitionModeMultiFrame != -1)
{
outputValue = mSet->mAcquisitionModeMultiFrame;
} else {
}
else
{
outputValue = mSet->mAcquisitionModeContinuous;
}
break;
case ADImageContinuous:
case ADImageContinuous:
outputValue = mSet->mAcquisitionModeContinuous;
break;
}
Expand Down