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)
112typedef struct OScInternal_Device OScDev_Device;
113typedef struct OScInternal_Setting OScDev_Setting;
129typedef struct RERR_Error OScDev_RichError;
130#define OScDev_RichError_OK ((OScDev_RichError *)NULL)
137 OScDev_LogLevel_Debug,
138 OScDev_LogLevel_Info,
139 OScDev_LogLevel_Warning,
140 OScDev_LogLevel_Error,
143typedef int32_t OScDev_ErrorCodeFormat;
169 OScDev_Error_Unknown = 10000,
170 OScDev_Error_Unsupported_Operation,
171 OScDev_Error_Illegal_Argument,
172 OScDev_Error_Device_Module_Already_Exists,
173 OScDev_Error_No_Such_Device_Module,
174 OScDev_Error_Driver_Not_Available,
175 OScDev_Error_Device_Already_Open,
176 OScDev_Error_Device_Not_Opened_For_LSM,
177 OScDev_Error_Device_Does_Not_Support_Clock,
178 OScDev_Error_Device_Does_Not_Support_Scanner,
179 OScDev_Error_Device_Does_Not_Support_Detector,
180 OScDev_Error_Wrong_Value_Type,
181 OScDev_Error_Setting_Not_Writable,
182 OScDev_Error_Wrong_Constraint_Type,
183 OScDev_Error_Unknown_Enum_Value_Name,
184 OScDev_Error_Acquisition_Running,
185 OScDev_Error_Not_Armed,
186 OScDev_Error_Waveform_Out_Of_Range,
187 OScDev_Error_Waveform_Memory_Size_Mismatch,
188 OScDev_Error_Data_Left_In_Fifo_After_Reading_Image,
202#define OScDev_CHECK(err, call) ((err = (call)) != OScDev_OK)
208typedef int32_t OScDev_TriggerSource;
210 OScDev_TriggerSource_Software,
211 OScDev_TriggerSource_External,
214typedef int32_t OScDev_ClockSource;
216 OScDev_ClockSource_Internal,
217 OScDev_ClockSource_External,
220typedef int32_t OScDev_ValueType;
222 OScDev_ValueType_String,
223 OScDev_ValueType_Bool,
224 OScDev_ValueType_Int32,
225 OScDev_ValueType_Float64,
226 OScDev_ValueType_Enum,
229typedef int32_t OScDev_ValueConstraint;
231 OScDev_ValueConstraint_None,
232 OScDev_ValueConstraint_DiscreteValues,
233 OScDev_ValueConstraint_Range,
280#ifndef OScDevInternal_BUILDING_OPENSCANLIB
315#define OScDev_MODULE_IMPL OScDev_ModuleImpl OScDevInternal_TheModuleImpl
329 OScDev_RichError *(*Error_RegisterCodeDomain)(
331 OScDev_ErrorCodeFormat codeFormat);
333 OScDev_RichError *error);
335 const char *message);
337 const char *domainName,
339 const char *message);
341 OScDev_RichError *cause,
342 const char *message);
344 OScDev_RichError *cause,
345 const char *domainName,
346 int32_t code,
const char *message);
349 OScDev_RichError *error);
351 OScDev_RichError *error);
353 OScDev_RichError *error);
355 OScDev_RichError *error);
357 char *buffer,
size_t bufsize);
359 OScDev_RichError *error,
char *buffer,
394 double rMin,
double rMax);
404 OScDev_Device **device,
407 OScDev_Device *device);
410 OScDev_Setting **setting,
const char *name,
411 OScDev_ValueType valueType,
414 OScDev_Setting *setting);
416 OScDev_Setting *setting);
430 OScDev_TriggerSource *startTrigger);
433 OScDev_ClockSource *clock);
445 uint32_t *yOffset, uint32_t *width,
450 uint32_t channel,
void *pixels);
563 OScDev_Error (*GetName)(OScDev_Device *device,
char *name);
640 double nominalRateHz,
641 double *actualRateHz);
724 uint32_t *nChannels);
733 uint32_t *bytesPerSample);
894 OScDev_Error (*IsEnabled)(OScDev_Setting *setting,
bool *enabled);
895 OScDev_Error (*IsWritable)(OScDev_Setting *setting,
bool *writable);
904 OScDev_Setting *setting, OScDev_ValueConstraint *constraintType);
905 OScDev_Error (*GetString)(OScDev_Setting *setting,
char *value);
906 OScDev_Error (*SetString)(OScDev_Setting *setting,
const char *value);
907 OScDev_Error (*GetBool)(OScDev_Setting *setting,
bool *value);
908 OScDev_Error (*SetBool)(OScDev_Setting *setting,
bool value);
909 OScDev_Error (*GetInt32)(OScDev_Setting *setting, int32_t *value);
910 OScDev_Error (*SetInt32)(OScDev_Setting *setting, int32_t value);
944 OScDev_Error (*GetFloat64)(OScDev_Setting *setting,
double *value);
945 OScDev_Error (*SetFloat64)(OScDev_Setting *setting,
double value);
977 OScDev_Error (*GetEnum)(OScDev_Setting *setting, uint32_t *value);
978 OScDev_Error (*SetEnum)(OScDev_Setting *setting, uint32_t value);
979 OScDev_Error (*GetEnumNumValues)(OScDev_Setting *setting, uint32_t *count);
980 OScDev_Error (*GetEnumNameForValue)(OScDev_Setting *setting,
981 uint32_t value,
char *name);
982 OScDev_Error (*GetEnumValueForName)(OScDev_Setting *setting,
983 uint32_t *value,
const char *name);
993#ifndef OScDevInternal_BUILDING_OPENSCANLIB
999#define OScDev_API static inline
1007 const char *message) {
1014 OScDev_Log(device, OScDev_LogLevel_Debug, message);
1019 OScDev_Log(device, OScDev_LogLevel_Info, message);
1024 const char *message) {
1025 OScDev_Log(device, OScDev_LogLevel_Warning, message);
1030 OScDev_Log(device, OScDev_LogLevel_Error, message);
1033OScDev_API OScDev_RichError *
1034OScDev_Error_RegisterCodeDomain(
const char *domainName,
1035 OScDev_ErrorCodeFormat codeFormat) {
1040OScDev_API
OScDev_Error OScDev_Error_ReturnAsCode(OScDev_RichError *error) {
1045OScDev_API OScDev_RichError *OScDev_Error_Create(
const char *message) {
1050OScDev_API OScDev_RichError *
1051OScDev_Error_CreateWithCode(
const char *domainName, int32_t code,
1052 const char *message) {
1057OScDev_API OScDev_RichError *OScDev_Error_Wrap(OScDev_RichError *cause,
1058 const char *message) {
1063OScDev_API OScDev_RichError *OScDev_Error_WrapWithCode(OScDev_RichError *cause,
1064 const char *domainName,
1066 const char *message) {
1071OScDev_API
const char *OScDev_Error_GetMessage(OScDev_RichError *error) {
1076OScDev_API
const char *OScDev_Error_GetDomain(OScDev_RichError *error) {
1081OScDev_API int32_t OScDev_Error_GetCode(OScDev_RichError *error) {
1086OScDev_API OScDev_RichError *OScDev_Error_GetCause(OScDev_RichError *error) {
1091OScDev_API
void OScDev_Error_Format(OScDev_RichError *error,
char *buffer,
1094 error, buffer, bufsize);
1097OScDev_API
void OScDev_Error_FormatRecursive(OScDev_RichError *error,
1098 char *buffer,
size_t bufsize) {
1103OScDev_API OScDev_RichError *OScDev_Error_AsRichError(
OScDev_Error code) {
1108OScDev_API
void OScDev_Error_Destroy(OScDev_RichError *error) {
1120OScDev_PtrArray_CreateFromNullTerminated(
void *
const *nullTerminatedArray) {
1147OScDev_API
void *OScDev_PtrArray_At(
const OScDev_PtrArray *arr,
size_t index) {
1159OScDev_NumArray_CreateFromNaNTerminated(
const double *nanTerminatedArray) {
1192OScDev_API
OScDev_NumRange *OScDev_NumRange_CreateContinuous(
double rMin,
1203OScDev_API
OScDev_NumRange *OScDev_NumRange_CreateDiscreteFromNaNTerminated(
1204 const double *nanTerminatedArray) {
1206 ->NumRange_CreateDiscreteFromNaNTerminated(
1210OScDev_API
void OScDev_NumRange_Destroy(
const OScDev_NumRange *range) {
1221OScDev_API
OScDev_Error OScDev_Device_Create(OScDev_Device **device,
1228OScDev_API
void *OScDev_Device_GetImplData(OScDev_Device *device) {
1233OScDev_API
OScDev_Error OScDev_Setting_Create(OScDev_Setting **setting,
1235 OScDev_ValueType valueType,
1242OScDev_API
void OScDev_Setting_Destroy(OScDev_Setting *setting) {
1247OScDev_API
void *OScDev_Setting_GetImplData(OScDev_Setting *setting) {
1329 uint32_t *xOffset, uint32_t *yOffset,
1330 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_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.
OScDev_PtrArray * OScDev_PtrArray_Create(void)
Create an array of objects.
OScDev_NumArray * OScDev_NumArray_Create(void)
Create an array of numbers.
void OScDev_Log_Warning(OScDev_Device *device, const char *message)
Log a warning-level message.
struct OScInternal_PtrArray OScDev_PtrArray
Dynamic or static array of pointers.
struct OScInternal_AcquisitionForDevice OScDev_Acquisition
Handle to an acquisition, for use by one participating device.
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(* Close)(OScDev_Device *device)
Close the connection to the device.
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.