Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
06e2db5
initial implementaiton with runtime validity checks
henrypinkard Feb 26, 2025
1931993
Working with runtime checks for required properties
henrypinkard Feb 27, 2025
30de537
add comment
henrypinkard Feb 27, 2025
8789d67
cleanup
henrypinkard Feb 28, 2025
5759cc0
more cleanup
henrypinkard Feb 28, 2025
88833b1
change comment
henrypinkard Feb 28, 2025
e5ea9ce
add code review fixes
henrypinkard Mar 4, 2025
3633c1f
split camera base class into Base and LegacyBase
henrypinkard Mar 5, 2025
652991c
restore using statements
henrypinkard Mar 5, 2025
9c0bb8b
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 5, 2025
40c3d02
initial commit resuming previous work on camera api. Still have a com…
henrypinkard Mar 5, 2025
49b01c5
fix namespace and constructor errors from previous commits
henrypinkard Mar 5, 2025
1cef0b6
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 5, 2025
a85a54f
resotre commented code
henrypinkard Mar 5, 2025
9ff9c1f
fix more namespace issues
henrypinkard Mar 5, 2025
e250f83
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 5, 2025
60bd4b4
working build with basler camera
henrypinkard Mar 5, 2025
d0b45a8
converted many methods to standard properties
henrypinkard Mar 5, 2025
979d571
added mechanism for skipping required standard property
henrypinkard Mar 5, 2025
c496157
add skip standard props
henrypinkard Mar 5, 2025
79017f4
remove required flag from standard properties. Default to required an…
henrypinkard Mar 6, 2025
b37e5c3
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 6, 2025
5e6ab94
split out old and new camera api paths and clean up basler
henrypinkard Mar 6, 2025
a39a41c
remove from skipped registry upon creation
henrypinkard Mar 6, 2025
44ade7a
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 6, 2025
aa32a0c
Basler: standard prop action handlers
henrypinkard Mar 6, 2025
758e20b
standard properties must declare values at initialization
henrypinkard Mar 6, 2025
fd46240
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 6, 2025
5a4a894
basler progress
henrypinkard Mar 6, 2025
efdf7f9
successful auto-query of standard properties from basler
henrypinkard Mar 6, 2025
7766760
Events work in progress
henrypinkard Mar 7, 2025
da30e68
add method for updating standard property values
henrypinkard Mar 7, 2025
35f171c
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 7, 2025
c3bd38e
fix bug
henrypinkard Mar 7, 2025
a7ab1e2
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 7, 2025
9eac505
add checker method
henrypinkard Mar 7, 2025
5cd87df
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 7, 2025
2e4a937
WIP dynamic properties
henrypinkard Mar 7, 2025
a73d75e
add ability to dynamically delete properties
henrypinkard Mar 7, 2025
d210f4f
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 7, 2025
afca015
refactoring dynamic properties
henrypinkard Mar 7, 2025
9ca35fa
fix method name
henrypinkard Mar 7, 2025
71d6155
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 7, 2025
0a5b88b
readd skips
henrypinkard Mar 7, 2025
e1ebc27
remove from map correctly
henrypinkard Mar 7, 2025
d3d5cbb
Merge branch 'standard_props' into camera_api2025
henrypinkard Mar 7, 2025
f34266d
generic event handler
henrypinkard Mar 7, 2025
e4c396d
backwards compat for sequences in new camera API
henrypinkard Mar 8, 2025
3d7c29d
fix bug and only register handler once
henrypinkard Mar 8, 2025
f345c8f
allow snap to call insertImage instead of keeping its own buffer
henrypinkard Mar 8, 2025
6adb4bf
allow snap to call insertImage instead of keeping its own buffer
henrypinkard Mar 8, 2025
8a0dd5d
remove future new camera api changes
henrypinkard Mar 8, 2025
46d6ea0
complete merge
henrypinkard Mar 8, 2025
6183045
fix ncomponents
henrypinkard Mar 8, 2025
aed4e97
changes for multi-channel cameras
henrypinkard Mar 8, 2025
f6594f2
merge multi channel camera changes
henrypinkard Mar 9, 2025
b385397
change variable name
henrypinkard Mar 9, 2025
3bdfa47
merge multichannel camera fixes
henrypinkard Mar 9, 2025
4b47590
always return
henrypinkard Mar 9, 2025
75764f1
delete unused
henrypinkard Mar 9, 2025
786d872
Merge branch 'snap_insert_image' into camera_api2025
henrypinkard Mar 9, 2025
224e5e1
fix compiler warnings
henrypinkard Mar 9, 2025
f972ed1
Merge branch 'snap_insert_image' into camera_api2025
henrypinkard Mar 9, 2025
2db1497
finished adding new camera API to core
henrypinkard Mar 9, 2025
2a68d14
camera events/callbacks and more standard properties
henrypinkard Mar 11, 2025
1f242d2
enable frame burst property
henrypinkard Mar 11, 2025
9001af1
comment out rolling shutter standard props for now
henrypinkard Mar 14, 2025
221409b
remove commented
henrypinkard Mar 14, 2025
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
Next Next commit
initial implementaiton with runtime validity checks
  • Loading branch information
henrypinkard committed Feb 26, 2025
commit 06e2db553ea374cee606621720b913d16efcafac
57 changes: 57 additions & 0 deletions MMDevice/DeviceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,62 @@ class CDeviceBase : public T
return properties_.CreateProperty(name, value, eType, readOnly, pAct, isPreInitProperty);
}

/**
* Creates a standard property -- a property with a predefined name, type, and possibly values.
* Standard properties can apply to all devices, or only some types, as specified in the
* switch statement below.
* Type, read-only and pre-init are fixed for the standard property
*
* @param property - the standard property enum
* @param value - initial value
* @param pAct - function object called on the property actions
*/
int CreateStandardProperty(MM::StandardProperty property, const char* value, MM::ActionFunctor* pAct = 0)
{
if (!IsValidStandardProperty(property)) {
return DEVICE_INVALID_PROPERTY;
}

// TODO: check if value is valid?

// Prepend the prefix marking it as a standard property and the delimiter
std::string fullName = g_KeywordStandardPropertyPrefix + "//" + property.name;

return properties_.CreateStandardProperty(property, value, pAct);
}

/**
* Checks if a standard property is applicable to this device type
* @param property - the standard property to check
* @return - true if applicable, false otherwise
*/
bool IsValidStandardProperty(MM::StandardProperty property) const
{
MM::DeviceType deviceType = T::Type;
return IsPropertyApplicableToDeviceType(property, deviceType);
}

/**
* Helper function to check if a standard property is applicable to a specific device type
* @param property - the standard property to check
* @param deviceType - the device type to check against
* @return - true if the property is applicable to the device type, false otherwise
*/
bool IsPropertyApplicableToDeviceType(MM::StandardProperty property, MM::DeviceType deviceType) const
{
// Iterate through the standard property list to find if this property
// is applicable to this device type
for (const MM::StandardPropAssociation& association : MM::g_StandardPropertyList)
{
if (strcmp(association.property.name, property.name) == 0 &&
association.deviceType == deviceType)
{
return true;
}
}
return false;
}

/**
* Creates a new property for the device.
* @param name - property name
Expand All @@ -596,6 +652,7 @@ class CDeviceBase : public T
*/
int CreatePropertyWithHandler(const char* name, const char* value, MM::PropertyType eType, bool readOnly,
int(U::*memberFunction)(MM::PropertyBase* pProp, MM::ActionType eAct), bool isPreInitProperty=false) {
// Check for reserved delimiter (handled in CreateProperty)
CPropertyAction* pAct = new CPropertyAction((U*) this, memberFunction);
return CreateProperty(name, value, eType, readOnly, pAct, isPreInitProperty);
}
Expand Down
34 changes: 34 additions & 0 deletions MMDevice/MMDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "DeviceUtils.h"
#include "ImageMetadata.h"
#include "DeviceThreads.h"
#include "Property.h"

#include <climits>
#include <cstdlib>
Expand Down Expand Up @@ -205,6 +206,39 @@ namespace MM {
};


////////////////////////////
///// Standard properties
////////////////////////////

// Specific standard properties
static const MM::StandardProperty g_BinningStandardProperty(
"Binning", // name
String, // type
false, // isReadOnly
false, // isPreInit
nullptr, // allowedValues
PropertyLimitUndefined, // lowerLimit
PropertyLimitUndefined // upperLimit
);

// A struct to encode which which device types have/require which standard properties
struct StandardPropAssociation {
const MM::StandardProperty& property;
MM::DeviceType deviceType; // which device types can use
bool required;
};

// This data structure associates standard properties with device types.
// each entry defines one property-device association and whether the
// standard property is required
static const StandardPropAssociation g_StandardPropertyList[] =
{
// propertyname deviceTypes required
{g_BinningStandardProperty, MM::CameraDevice, false}
};



/**
* Generic device interface.
*/
Expand Down
1 change: 1 addition & 0 deletions MMDevice/MMDeviceConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#define DEVICE_SEQUENCE_TOO_LARGE 39
#define DEVICE_OUT_OF_MEMORY 40
#define DEVICE_NOT_YET_IMPLEMENTED 41
#define DEVICE_MISSING_REQUIRED_PROPERTY 42


namespace MM {
Expand Down
18 changes: 17 additions & 1 deletion MMDevice/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,23 @@ unsigned MM::PropertyCollection::GetSize() const
return (unsigned) properties_.size();
}

int MM::PropertyCollection::CreateProperty(const char* pszName, const char* pszValue, MM::PropertyType eType, bool bReadOnly, MM::ActionFunctor* pAct, bool isPreInitProperty)
int MM::PropertyCollection::CreateStandardProperty(StandardProperty property, const char* value, ActionFunctor* pAct)
{
return DoCreateProperty(property.name, value, property.type, property.isReadOnly, pAct, property.isPreInit);
}

int MM::PropertyCollection::CreateProperty(const char* name, const char* value, PropertyType eType, bool bReadOnly, ActionFunctor* pAct=0, bool isPreInitProperty=false)
{
// disallow properties that begin with the reserved prefix for standard properties
// std prefic + delimiter + property name
std::string prefixAndDelim = std::string(g_KeywordStandardPropertyPrefix) + std::string("//");
if (std::string(name).find(prefixAndDelim) == 0)
return DEVICE_INVALID_PROPERTY;

return DoCreateProperty(name, value, eType, bReadOnly, pAct, isPreInitProperty);
}

int MM::PropertyCollection::DoCreateProperty(const char* pszName, const char* pszValue, MM::PropertyType eType, bool bReadOnly, MM::ActionFunctor* pAct, bool isPreInitProperty)
{
// check if the name already exists
if (Find(pszName))
Expand Down
45 changes: 44 additions & 1 deletion MMDevice/Property.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,48 @@

namespace MM {

// Standard Properties
const char* const g_KeywordStandardPropertyPrefix = "api";

// Define NaN for use in property definitions
const double PropertyLimitUndefined = std::numeric_limits<double>::quiet_NaN();

// Standard property metadata structure
class StandardProperty {
public:
StandardProperty(
const char* name,
PropertyType type,
bool isReadOnly,
bool isPreInit,
const char* const* allowedValues,
double lowerLimit,
double upperLimit
) :
name(name),
type(type),
isReadOnly(isReadOnly),
isPreInit(isPreInit),
allowedValues(allowedValues),
lowerLimit(lowerLimit),
upperLimit(upperLimit)
{}

// Helper to check if limits are defined
bool hasLimits() const {
return !std::isnan(lowerLimit) && !std::isnan(upperLimit);
}

const char* name; // Full property name (without prefix)
PropertyType type; // Float, String, or Integer
bool isReadOnly; // Whether property is read-only
bool isPreInit; // Whether property should be set before initialization
const char* const* allowedValues; // Array of allowed string values (nullptr if not restricted)
double lowerLimit; // Lower limit for numeric properties (NaN if not limited)
double upperLimit; // Upper limit for numeric properties (NaN if not limited)
};


/**
* Base API for all device properties.
* This interface is used by action functors.
Expand Down Expand Up @@ -437,6 +479,7 @@ class PropertyCollection
PropertyCollection();
~PropertyCollection();

int CreateStandardProperty(StandardProperty property, const char* value, ActionFunctor* pAct=0);
int CreateProperty(const char* name, const char* value, PropertyType eType, bool bReadOnly, ActionFunctor* pAct=0, bool isPreInitProperty=false);
int RegisterAction(const char* name, ActionFunctor* fpAct);
int SetAllowedValues(const char* name, std::vector<std::string>& values);
Expand All @@ -457,9 +500,9 @@ class PropertyCollection
int Apply(const char* Name);

private:
int DoCreateProperty(const char* name, const char* value, PropertyType eType, bool bReadOnly, ActionFunctor* pAct=0, bool isPreInitProperty=false);
typedef std::map<std::string, Property*> CPropArray;
CPropArray properties_;
};


} // namespace MM