55 #define OScDevInternal_MAKE_VERSION(major, minor) \
56 (((uint32_t)(major) << 16) | (uint16_t)(minor))
93 #define OScDevInternal_ABI_VERSION OScDevInternal_MAKE_VERSION(13, 0)
105 #define OScDev_MAX_STR_SIZE 512
108 #define OScDev_MAX_STR_LEN (OScDev_MAX_STR_SIZE - 1)
112 typedef struct OScInternal_Device OScDev_Device;
113 typedef struct OScInternal_Setting OScDev_Setting;
114 typedef struct OScInternal_AcquisitionForDevice OScDev_Acquisition;
115 typedef struct RERR_Error OScDev_RichError;
116 #define OScDev_RichError_OK ((OScDev_RichError *)NULL)
123 OScDev_LogLevel_Debug,
124 OScDev_LogLevel_Info,
125 OScDev_LogLevel_Warning,
126 OScDev_LogLevel_Error,
129 typedef int32_t OScDev_ErrorCodeFormat;
155 OScDev_Error_Unknown = 10000,
156 OScDev_Error_Unsupported_Operation,
157 OScDev_Error_Illegal_Argument,
158 OScDev_Error_Device_Module_Already_Exists,
159 OScDev_Error_No_Such_Device_Module,
160 OScDev_Error_Driver_Not_Available,
161 OScDev_Error_Device_Already_Open,
162 OScDev_Error_Device_Not_Opened_For_LSM,
163 OScDev_Error_Device_Does_Not_Support_Clock,
164 OScDev_Error_Device_Does_Not_Support_Scanner,
165 OScDev_Error_Device_Does_Not_Support_Detector,
166 OScDev_Error_Wrong_Value_Type,
167 OScDev_Error_Setting_Not_Writable,
168 OScDev_Error_Wrong_Constraint_Type,
169 OScDev_Error_Unknown_Enum_Value_Name,
170 OScDev_Error_Acquisition_Running,
171 OScDev_Error_Not_Armed,
172 OScDev_Error_Waveform_Out_Of_Range,
173 OScDev_Error_Waveform_Memory_Size_Mismatch,
174 OScDev_Error_Data_Left_In_Fifo_After_Reading_Image,
188 #define OScDev_CHECK(err, call) ((err = (call)) != OScDev_OK)
194 typedef int32_t OScDev_TriggerSource;
196 OScDev_TriggerSource_Software,
197 OScDev_TriggerSource_External,
200 typedef int32_t OScDev_ClockSource;
202 OScDev_ClockSource_Internal,
203 OScDev_ClockSource_External,
206 typedef int32_t OScDev_ValueType;
208 OScDev_ValueType_String,
209 OScDev_ValueType_Bool,
210 OScDev_ValueType_Int32,
211 OScDev_ValueType_Float64,
212 OScDev_ValueType_Enum,
215 typedef int32_t OScDev_ValueConstraint;
217 OScDev_ValueConstraint_None,
218 OScDev_ValueConstraint_DiscreteValues,
219 OScDev_ValueConstraint_Range,
266 #ifndef OScDevInternal_BUILDING_OPENSCANLIB
301 #define OScDev_MODULE_IMPL OScDev_ModuleImpl OScDevInternal_TheModuleImpl
315 OScDev_RichError *(*Error_RegisterCodeDomain)(
317 OScDev_ErrorCodeFormat codeFormat);
319 OScDev_RichError *error);
321 const char *message);
323 const char *domainName,
325 const char *message);
327 OScDev_RichError *cause,
328 const char *message);
330 OScDev_RichError *cause,
331 const char *domainName,
332 int32_t code,
const char *message);
335 OScDev_RichError *error);
337 OScDev_RichError *error);
339 OScDev_RichError *error);
341 OScDev_RichError *error);
343 char *buffer,
size_t bufsize);
345 OScDev_RichError *error,
char *buffer,
380 double rMin,
double rMax);
390 OScDev_Device **device,
393 OScDev_Device *device);
396 OScDev_Setting **setting,
const char *name,
397 OScDev_ValueType valueType,
400 OScDev_Setting *setting);
402 OScDev_Setting *setting);
406 OScDev_Acquisition *acq,
409 OScDev_Acquisition *acq,
412 OScDev_Acquisition *acq,
416 OScDev_TriggerSource *startTrigger);
418 OScDev_Acquisition *acq,
419 OScDev_ClockSource *clock);
422 OScDev_Acquisition *acq);
424 OScDev_Acquisition *acq);
426 OScDev_Acquisition *acq);
428 OScDev_Acquisition *acq);
430 OScDev_Acquisition *acq, uint32_t *xOffset,
431 uint32_t *yOffset, uint32_t *width,
435 OScDev_Acquisition *acq,
436 uint32_t channel,
void *pixels);
549 OScDev_Error (*GetName)(OScDev_Device *device,
char *name);
619 double nominalRateHz,
620 double *actualRateHz);
703 uint32_t *nChannels);
712 uint32_t *bytesPerSample);
843 OScDev_Error (*IsEnabled)(OScDev_Setting *setting,
bool *enabled);
844 OScDev_Error (*IsWritable)(OScDev_Setting *setting,
bool *writable);
853 OScDev_Setting *setting, OScDev_ValueConstraint *constraintType);
854 OScDev_Error (*GetString)(OScDev_Setting *setting,
char *value);
855 OScDev_Error (*SetString)(OScDev_Setting *setting,
const char *value);
856 OScDev_Error (*GetBool)(OScDev_Setting *setting,
bool *value);
857 OScDev_Error (*SetBool)(OScDev_Setting *setting,
bool value);
858 OScDev_Error (*GetInt32)(OScDev_Setting *setting, int32_t *value);
859 OScDev_Error (*SetInt32)(OScDev_Setting *setting, int32_t value);
893 OScDev_Error (*GetFloat64)(OScDev_Setting *setting,
double *value);
894 OScDev_Error (*SetFloat64)(OScDev_Setting *setting,
double value);
926 OScDev_Error (*GetEnum)(OScDev_Setting *setting, uint32_t *value);
927 OScDev_Error (*SetEnum)(OScDev_Setting *setting, uint32_t value);
928 OScDev_Error (*GetEnumNumValues)(OScDev_Setting *setting, uint32_t *count);
929 OScDev_Error (*GetEnumNameForValue)(OScDev_Setting *setting,
930 uint32_t value,
char *name);
931 OScDev_Error (*GetEnumValueForName)(OScDev_Setting *setting,
932 uint32_t *value,
const char *name);
942 #ifndef OScDevInternal_BUILDING_OPENSCANLIB
948 #define OScDev_API static inline
956 const char *message) {
963 OScDev_Log(device, OScDev_LogLevel_Debug, message);
968 OScDev_Log(device, OScDev_LogLevel_Info, message);
973 const char *message) {
974 OScDev_Log(device, OScDev_LogLevel_Warning, message);
979 OScDev_Log(device, OScDev_LogLevel_Error, message);
982 OScDev_API OScDev_RichError *
983 OScDev_Error_RegisterCodeDomain(
const char *domainName,
984 OScDev_ErrorCodeFormat codeFormat) {
989 OScDev_API
OScDev_Error OScDev_Error_ReturnAsCode(OScDev_RichError *error) {
994 OScDev_API OScDev_RichError *OScDev_Error_Create(
const char *message) {
999 OScDev_API OScDev_RichError *
1000 OScDev_Error_CreateWithCode(
const char *domainName, int32_t code,
1001 const char *message) {
1006 OScDev_API OScDev_RichError *OScDev_Error_Wrap(OScDev_RichError *cause,
1007 const char *message) {
1012 OScDev_API OScDev_RichError *OScDev_Error_WrapWithCode(OScDev_RichError *cause,
1013 const char *domainName,
1015 const char *message) {
1020 OScDev_API
const char *OScDev_Error_GetMessage(OScDev_RichError *error) {
1025 OScDev_API
const char *OScDev_Error_GetDomain(OScDev_RichError *error) {
1030 OScDev_API int32_t OScDev_Error_GetCode(OScDev_RichError *error) {
1035 OScDev_API OScDev_RichError *OScDev_Error_GetCause(OScDev_RichError *error) {
1040 OScDev_API
void OScDev_Error_Format(OScDev_RichError *error,
char *buffer,
1043 error, buffer, bufsize);
1046 OScDev_API
void OScDev_Error_FormatRecursive(OScDev_RichError *error,
1047 char *buffer,
size_t bufsize) {
1052 OScDev_API OScDev_RichError *OScDev_Error_AsRichError(
OScDev_Error code) {
1057 OScDev_API
void OScDev_Error_Destroy(OScDev_RichError *error) {
1069 OScDev_PtrArray_CreateFromNullTerminated(
void *
const *nullTerminatedArray) {
1096 OScDev_API
void *OScDev_PtrArray_At(
const OScDev_PtrArray *arr,
size_t index) {
1108 OScDev_NumArray_CreateFromNaNTerminated(
const double *nanTerminatedArray) {
1141 OScDev_API
OScDev_NumRange *OScDev_NumRange_CreateContinuous(
double rMin,
1152 OScDev_API
OScDev_NumRange *OScDev_NumRange_CreateDiscreteFromNaNTerminated(
1153 const double *nanTerminatedArray) {
1155 ->NumRange_CreateDiscreteFromNaNTerminated(
1159 OScDev_API
void OScDev_NumRange_Destroy(
const OScDev_NumRange *range) {
1164 OScDev_API
void OScDev_NumRange_AppendDiscrete(
OScDev_NumRange *range,
1170 OScDev_API
OScDev_Error OScDev_Device_Create(OScDev_Device **device,
1177 OScDev_API
void *OScDev_Device_GetImplData(OScDev_Device *device) {
1182 OScDev_API
OScDev_Error OScDev_Setting_Create(OScDev_Setting **setting,
1184 OScDev_ValueType valueType,
1191 OScDev_API
void OScDev_Setting_Destroy(OScDev_Setting *setting) {
1196 OScDev_API
void *OScDev_Setting_GetImplData(OScDev_Setting *setting) {
1204 OScDev_Acquisition *acq,
bool *isRequested) {
1212 OScDev_Acquisition *acq,
bool *isRequested) {
1220 OScDev_Acquisition *acq,
bool *isRequested) {
1235 OScDev_Acquisition *acq, OScDev_TriggerSource *startTrigger) {
1250 OScDev_Acquisition *acq, OScDev_ClockSource *clock) {
1262 OScDev_API
double OScDev_Acquisition_GetPixelRate(OScDev_Acquisition *acq) {
1267 OScDev_API uint32_t OScDev_Acquisition_GetResolution(OScDev_Acquisition *acq) {
1272 OScDev_API
double OScDev_Acquisition_GetZoomFactor(OScDev_Acquisition *acq) {
1277 OScDev_API
void OScDev_Acquisition_GetROI(OScDev_Acquisition *acq,
1278 uint32_t *xOffset, uint32_t *yOffset,
1279 uint32_t *width, uint32_t *height) {
bool OScDev_Acquisition_CallFrameCallback(OScDev_Acquisition *acq, uint32_t channel, void *pixels)
Send acquired data for one channel of a frame.
OScDev_Error OScDev_Acquisition_IsDetectorRequested(OScDev_Acquisition *acq, bool *isRequested)
OScDev_PtrArray * OScDev_PtrArray_Create(void)
Create an array of objects.
OScDev_Error OScDev_Acquisition_GetClockSource(OScDev_Acquisition *acq, OScDev_ClockSource *clock)
Determine the scanner and detector clock source for the given acquisition.
void OScDev_PtrArray_Destroy(const OScDev_PtrArray *arr)
Destroy (free) an array of objects.
void OScDev_Log_Error(OScDev_Device *device, const char *message)
Log an error-level message.
OScDev_Error OScDev_Acquisition_GetClockStartTriggerSource(OScDev_Acquisition *acq, OScDev_TriggerSource *startTrigger)
Determine the start trigger source for the clock for the given acquisition.
void OScDev_Log_Info(OScDev_Device *device, const char *message)
Log an info-level message.
void OScDev_Log_Debug(OScDev_Device *device, const char *message)
Log a debug-level message.
void OScDev_Log_Warning(OScDev_Device *device, const char *message)
Log a warning-level message.
OScDev_NumArray * OScDev_NumArray_Create(void)
Create an array of numbers.
struct OScInternal_PtrArray OScDev_PtrArray
Dynamic or static array of pointers.
struct OScInternal_NumRange OScDev_NumRange
Continuous or discrete numerical range.
int32_t OScDev_Error
Error return value.
OScDev_Error OScDev_Acquisition_IsScannerRequested(OScDev_Acquisition *acq, bool *isRequested)
void OScDev_Log(OScDev_Device *device, OScDev_LogLevel level, const char *message)
Log a message.
int32_t OScDev_LogLevel
Log level.
uint32_t OScDev_Acquisition_GetNumberOfFrames(OScDev_Acquisition *acq)
Determine the requested number of frames for the given acquisition.
struct OScInternal_NumArray OScDev_NumArray
Dynamic or static array of numbers.
OScDev_Error OScDev_Acquisition_IsClockRequested(OScDev_Acquisition *acq, bool *isRequested)
void OScDev_NumArray_Destroy(const OScDev_NumArray *arr)
Destroy (free) an array of numbers.
void OScDev_NumArray_Append(OScDev_NumArray *arr, double val)
Append a value to an array.
void OScDev_PtrArray_Append(OScDev_PtrArray *arr, void *obj)
Append an object to an array.
@ OScDev_ErrorCodeFormat_U16
16-bit unsigned integer, decimal
@ OScDev_ErrorCodeFormat_I16
16-bit signed integer, decimal
@ OScDev_ErrorCodeFormat_HexNoPad
Modifier to remove leading zeros from hex formats.
@ OScDev_ErrorCodeFormat_Hex32
32-bit unsigned integer, hexadecimal
@ OScDev_ErrorCodeFormat_U32
32-bit unsigned integer, decimal
@ OScDev_ErrorCodeFormat_I32
32-bit signed integer, decimal
@ OScDev_ErrorCodeFormat_Hex16
16-bit unsigned integer, hexadecimal
struct OScDevInternal_Interface * OScDevInternal_FunctionTable
Pointer to the interface function table provided by OpenScanLib.
OScDev_ModuleImpl OScDevInternal_TheModuleImpl
Pointer to the module implementation provided by the device module.
Interface function table for module to call OpenScanLib.
OScDev_Error(* Start)(OScDev_Device *device)
Start the clock from software.
OScDev_Error(* HasDetector)(OScDev_Device *device, bool *hasDetector)
Return true if this device can perform detection.
OScDev_Error(* HasClock)(OScDev_Device *device, bool *hasClock)
OScDev_Error(* ReleaseInstance)(OScDev_Device *device)
Free the private data for a device.
OScDev_Error(* MakeSettings)(OScDev_Device *device, OScDev_PtrArray **settings)
Create the settings for a device.
OScDev_Error(* Arm)(OScDev_Device *device, OScDev_Acquisition *acq)
Prepare the clock, scanner, and/or detector for an acquisition.
OScDev_Error(* GetActualPixelRate)(OScDev_Device *device, double nominalRateHz, double *actualRateHz)
Return the actual pixel rate with best known accuracy.
OScDev_Error(* IsROIScanSupported)(OScDev_Device *device, bool *supported)
Return whether the scanner can perform subregion scans.
OScDev_Error(* GetRasterWidths)(OScDev_Device *device, OScDev_NumRange **widths)
Return the allowed widths of the raster ROI.
OScDev_Error(* GetNumberOfChannels)(OScDev_Device *device, uint32_t *nChannels)
Return the number of channels given current settings.
OScDev_Error(* GetResolutions)(OScDev_Device *device, OScDev_NumRange **resolutions)
Return the allowed scanner resolutions.
OScDev_Error(* GetRasterHeights)(OScDev_Device *device, OScDev_NumRange **heights)
Return the allowed heights of the raster ROI.
OScDev_Error(* HasScanner)(OScDev_Device *device, bool *hasScanner)
Return true if this device can perform scanning.
OScDev_Error(* IsRunning)(OScDev_Device *device, bool *isRunning)
Return true if this device is armed or running an acquisition.
OScDev_Error(* EnumerateInstances)(OScDev_PtrArray **devices)
Create instances for each physically available device.
OScDev_Error(* Open)(OScDev_Device *device)
Establish a connection to the device.
OScDev_Error(* GetPixelRates)(OScDev_Device *device, OScDev_NumRange **pixelRatesHz)
Return the allowed pixel rates.
OScDev_Error(* GetZoomFactors)(OScDev_Device *device, OScDev_NumRange **zooms)
Return the allowed zoom factors.
OScDev_Error(* GetBytesPerSample)(OScDev_Device *device, uint32_t *bytesPerSample)
Return the bytes per sample given current settings.
OScDev_Error(* Wait)(OScDev_Device *device)
Wait for any current acquisition to finish.
OScDev_Error(* Stop)(OScDev_Device *device)
Stop the current acquisition and disarm.
The module implementation function table.
OScDev_Error(* Open)(void)
Called before OpenScanLib accesses any other functions in this module.
OScDev_Error(* Close)(void)
Called after OpenScanLib has finished accessing this module.
const bool supportsRichErrors
Whether the device module supports RichErrors.
OScDev_Error(* GetDeviceImpls)(OScDev_PtrArray **deviceImpls)
Return the device implementations available in this module.
const char * displayName
Human-readable name of this module.
OScDev_Error(* GetFloat64Range)(OScDev_Setting *setting, double *min, double *max)
Get the range of an float64 setting with range constraint.
void(* Release)(OScDev_Setting *setting)
Free the private data associated with a setting, if any.
OScDev_Error(* GetFloat64DiscreteValues)(OScDev_Setting *setting, OScDev_NumArray **values)
Get the allowed values of an float64 setting with discrete values constraint.
OScDev_Error(* GetInt32Range)(OScDev_Setting *setting, int32_t *min, int32_t *max)
Get the range of an int32 setting with range constraint.
OScDev_Error(* GetNumericConstraintType)(OScDev_Setting *setting, OScDev_ValueConstraint *constraintType)
Get the type of value constraint of an int32 or float64 setting.
OScDev_Error(* GetInt32DiscreteValues)(OScDev_Setting *setting, OScDev_NumArray **values)
Get the allowed values of an int32 setting with discrete values constraint.