// // idlpgr_RetrieveBuffer // // Transfer image to Point Grey image buffer. // void IDL_CDECL idlpgr_RetrieveBuffer(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; fc2Image *image; context = (fc2Context) IDL_ULong64Scalar(argv[0]); image = (fc2Image *) IDL_ULong64Scalar(argv[1]); error = fc2RetrieveBuffer(context, image); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not retrieve image buffer", error); }
// // idlpgr_AllocateImage // // Allocate IDL buffer for image data and transfer image. // argv[0]: image // IDL_VPTR IDL_CDECL idlpgr_AllocateImage(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Image *image; IDL_MEMINT ndims, dim[IDL_MAX_ARRAY_DIM]; IDL_VPTR idl_image; UCHAR *pd; image = (fc2Image *) IDL_ULong64Scalar(argv[0]); if (image->cols == image->stride) { ndims = 2; dim[0] = image->cols; dim[1] = image->rows; } else { ndims = 3; dim[0] = 3; dim[1] = image->cols; dim[2] = image->rows; } pd = (UCHAR *) IDL_MakeTempArray(IDL_TYP_BYTE, ndims, dim, IDL_ARR_INI_NOP, &idl_image); memcpy(pd, image->pData, image->rows*image->stride); return idl_image; }
// // idlpgr_GetCameraFromIndex // IDL_VPTR IDL_CDECL idlpgr_GetCameraFromIndex(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; int camera; fc2PGRGuid guid; IDL_VPTR idl_guid; IDL_ULONG *pd; IDL_MEMINT dim = 4; int i; context = (fc2Context) IDL_ULong64Scalar(argv[0]); camera = (argc == 2) ? (int) IDL_LongScalar(argv[1]) : 0; error = fc2GetCameraFromIndex(context, camera, &guid); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not acquire specified camera", error); // transfer camera guid to IDL as a vector of ULONG values pd = (IDL_ULONG *) IDL_MakeTempVector(IDL_TYP_ULONG, dim, IDL_ARR_INI_NOP, &idl_guid); for (i = 0; i < 4; i++) pd[i] = guid.value[i]; return idl_guid; }
// // idlpgr_GetImage // // Transfer image data to preallocated IDL buffer // void IDL_CDECL idlpgr_GetImage(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Image *image; IDL_MEMINT ndims, dim[IDL_MAX_ARRAY_DIM]; IDL_VPTR idl_image; UCHAR *pd; image = (fc2Image *) IDL_ULong64Scalar(argv[0]); if (image->cols == image->stride) { ndims = 2; dim[0] = image->cols; dim[1] = image->rows; } else { ndims = 3; dim[0] = 3; dim[1] = image->cols; dim[2] = image->rows; } idl_image = argv[1]; IDL_ENSURE_ARRAY(idl_image); if (idl_image->value.arr->arr_len == image->stride*image->rows){ pd = idl_image->value.arr->data; } else { IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "IDL buffer is not the same size as the image.", error); } memcpy(pd, image->pData, image->rows*image->stride); }
// unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, // char *to, const char *from, // unsigned long length); static IDL_VPTR IDL_mg_mysql_real_escape_string(int argc, IDL_VPTR *argv) { unsigned long length; IDL_ENSURE_ARRAY(argv[1]) IDL_ENSURE_ARRAY(argv[2]) length = mysql_real_escape_string((MYSQL *)argv[0]->value.ptrint, (char *) argv[1]->value.arr->data, (char *) argv[2]->value.arr->data, IDL_ULong64Scalar(argv[3])); return IDL_GettmpULong64(length); }
// MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, // const char *user, const char *passwd, // const char *db, unsigned int port, // const char *unix_socket, // unsigned long clientflag); static IDL_VPTR IDL_mg_mysql_real_connect(int argc, IDL_VPTR *argv) { MYSQL *mysql = mysql_real_connect((MYSQL *) argv[0]->value.ptrint, IDL_VarGetString(argv[1]), IDL_VarGetString(argv[2]), IDL_VarGetString(argv[3]), argv[4]->value.str.slen == 0 ? NULL : IDL_VarGetString(argv[4]), IDL_ULongScalar(argv[5]), argv[6]->value.str.slen == 0 ? NULL : IDL_VarGetString(argv[6]), IDL_ULong64Scalar(argv[7])); return IDL_GettmpMEMINT((IDL_MEMINT) mysql); }
// // idlpgr_DestroyContext // void IDL_CDECL idlpgr_DestroyContext(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; context = (fc2Context) IDL_ULong64Scalar(argv[0]); error = fc2DestroyContext(context); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not destroy specified context", error); }
// // idlpgr_DestroyImage // void IDL_CDECL idlpgr_DestroyImage(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Image *image; image = (fc2Image *) IDL_ULong64Scalar(argv[0]); error = fc2DestroyImage(image); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not destroy image", error); IDL_MemFree(image, NULL, 0); }
// // idlpgr_StopCapture // void IDL_CDECL idlpgr_StopCapture(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; context = (fc2Context) IDL_ULong64Scalar(argv[0]); error = fc2StopCapture(context); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not stop capture", error); }
// // idlpgr_GetCameraInfo // // Returns a subset of the fc2CameraInfo structure // IDL_VPTR IDL_CDECL idlpgr_GetCameraInfo(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; fc2CameraInfo camerainfo; IDL_StructDefPtr sdef; char *pd; IDL_MEMINT one = 1; IDL_VPTR idl_camerainfo; context = (fc2Context) IDL_ULong64Scalar(argv[0]); error = fc2GetCameraInfo(context, &camerainfo); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not read camera info", error); static IDL_STRUCT_TAG_DEF tags[] = { { "SERIALNUMBER", 0, (void *) IDL_TYP_ULONG }, { "ISCOLORCAMERA", 0, (void *) IDL_TYP_LONG }, { "MODELNAME", 0, (void *) IDL_TYP_STRING }, { "VENDORNAME", 0, (void *) IDL_TYP_STRING }, { "SENSORINFO", 0, (void *) IDL_TYP_STRING }, { "SENSORRESOLUTION", 0, (void *) IDL_TYP_STRING }, { "DRIVERNAME", 0, (void *) IDL_TYP_STRING }, { "FIRMWAREVERSION", 0, (void *) IDL_TYP_STRING }, { 0 } }; sdef = IDL_MakeStruct("fc2CameraInfo", tags); pd = IDL_MakeTempStruct(sdef, 1, &one, &idl_camerainfo, TRUE); *(IDL_ULONG *) pd = camerainfo.serialNumber; pd += sizeof(IDL_ULONG); *(IDL_LONG *) pd = camerainfo.isColorCamera; pd += sizeof(IDL_LONG); IDL_StrStore((IDL_STRING *) pd, camerainfo.modelName); pd += sizeof(IDL_STRING); IDL_StrStore((IDL_STRING *) pd, camerainfo.vendorName); pd += sizeof(IDL_STRING); IDL_StrStore((IDL_STRING *) pd, camerainfo.sensorInfo); pd += sizeof(IDL_STRING); IDL_StrStore((IDL_STRING *) pd, camerainfo.sensorResolution); pd += sizeof(IDL_STRING); IDL_StrStore((IDL_STRING *) pd, camerainfo.driverName); pd += sizeof(IDL_STRING); IDL_StrStore((IDL_STRING *) pd, camerainfo.firmwareVersion); return idl_camerainfo; }
// // idlpgr_GetNumOfCameras // IDL_VPTR IDL_CDECL idlpgr_GetNumOfCameras(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; unsigned int ncameras = 0; context = (fc2Context) IDL_ULong64Scalar(argv[0]); error = fc2GetNumOfCameras(context, &ncameras); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not count cameras", error); return IDL_GettmpLong(ncameras); }
// // idlpgr_WriteRegister // // Write unsigned integer to specified register // void IDL_CDECL idlpgr_WriteRegister(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; unsigned int address, value; context = (fc2Context) IDL_ULong64Scalar(argv[0]); address = (unsigned int) IDL_ULongScalar(argv[1]); value = (unsigned int) IDL_ULongScalar(argv[2]); error = fc2WriteRegister(context, address, value); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not write value to specified register", error); }
// // idlpgr_GetPropertyInfo // // Get information about property // // Reference: FlyCapture2Defs_C.h // IDL_VPTR IDL_CDECL idlpgr_GetPropertyInfo(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; fc2PropertyInfo info; static IDL_MEMINT one = 1; static IDL_MEMINT r[] = {1, 8}; static IDL_MEMINT s[] = {1, MAX_STRING_LENGTH}; IDL_VPTR idl_info; IDL_StructDefPtr sdef; char *pd; context = (fc2Context) IDL_ULong64Scalar(argv[0]); info.type = (fc2PropertyType) IDL_LongScalar(argv[1]); error = fc2GetPropertyInfo(context, &info); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not get requested property information", error); static IDL_STRUCT_TAG_DEF tags[] = { { "TYPE", 0, (void *) IDL_TYP_LONG }, { "PRESENT", 0, (void *) IDL_TYP_LONG }, { "AUTOSUPPORTED", 0, (void *) IDL_TYP_LONG }, { "MANUALSUPPORTED", 0, (void *) IDL_TYP_LONG }, { "ONOFFSUPPORTED", 0, (void *) IDL_TYP_LONG }, { "ONEPUSHSUPPORTED", 0, (void *) IDL_TYP_LONG }, { "ABSVALSUPPORTED", 0, (void *) IDL_TYP_LONG }, { "READOUTSUPPORTED", 0, (void *) IDL_TYP_LONG }, { "MIN", 0, (void *) IDL_TYP_ULONG }, { "MAX", 0, (void *) IDL_TYP_ULONG }, { "ABSMIN", 0, (void *) IDL_TYP_FLOAT }, { "ABSMAX", 0, (void *) IDL_TYP_FLOAT }, { "PUNITS", s, (void *) IDL_TYP_BYTE }, { "PUNITABBR", s, (void *) IDL_TYP_BYTE }, { "RESERVED", r, (void *) IDL_TYP_ULONG }, { 0 } }; sdef = IDL_MakeStruct("fc2PropertyInfo", tags); pd = IDL_MakeTempStruct(sdef, 1, &one, &idl_info, TRUE); memcpy(pd, (char *) &info, sizeof(fc2PropertyInfo)); return idl_info; }
// // idlpgr_ReadRegister // // Read contents of specified register // IDL_VPTR IDL_CDECL idlpgr_ReadRegister(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; unsigned int address, value; context = (fc2Context) IDL_ULong64Scalar(argv[0]); address = (unsigned int) IDL_ULongScalar(argv[1]); error = fc2ReadRegister(context, address, &value); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not read from specified register", error); return IDL_GettmpULong((IDL_ULONG) value); }
// // idlpgr_GetProperty // // Read property values from camera // // Reference: FlyCapture2Defs_C.h // IDL_VPTR IDL_CDECL idlpgr_GetProperty(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; fc2Property property; static IDL_MEMINT r[] = {1, 8}; static IDL_MEMINT one = 1; IDL_VPTR idl_property; IDL_StructDefPtr sdef; char *pd; context = (fc2Context) IDL_ULong64Scalar(argv[0]); property.type = (fc2PropertyType) IDL_LongScalar(argv[1]); error = fc2GetProperty(context, &property); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not get requested property", error); static IDL_STRUCT_TAG_DEF tags[] = { { "TYPE", 0, (void *) IDL_TYP_LONG }, { "PRESENT", 0, (void *) IDL_TYP_LONG }, { "ABSCONTROL", 0, (void *) IDL_TYP_LONG }, { "ONEPUSH", 0, (void *) IDL_TYP_LONG }, { "ONOFF", 0, (void *) IDL_TYP_LONG }, { "AUTOMANUALMODE", 0, (void *) IDL_TYP_LONG }, { "VALUEA", 0, (void *) IDL_TYP_ULONG }, { "VALUEB", 0, (void *) IDL_TYP_ULONG }, { "ABSVALUE", 0, (void *) IDL_TYP_FLOAT }, { "RESERVED", r, (void *) IDL_TYP_ULONG }, { 0 } }; sdef = IDL_MakeStruct("fc2Property", tags); pd = IDL_MakeTempStruct(sdef, 1, &one, &idl_property, TRUE); memcpy(pd, (char *) &property, sizeof(fc2Property)); return idl_property; }
// // idlpgr_SetProperty // // Write property values to camera // // Reference: FlyCapture2Defs_C.h // void IDL_CDECL idlpgr_SetProperty(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; fc2Property property; char *sname; context = (fc2Context) IDL_ULong64Scalar(argv[0]); IDL_ENSURE_STRUCTURE(argv[1]); IDL_StructTagNameByIndex(argv[1]->value.s.sdef, 0, IDL_MSG_LONGJMP, &sname); if (strcmp(sname, "fc2Property")) IDL_MessageFromBlock(msgs, M_IDLPGR_ERROR, IDL_MSG_LONGJMP, "Argument is not of type fc2Property."); memcpy((char *) &property, (char *) argv[1]->value.s.arr->data, sizeof(fc2Property)); error = fc2SetProperty(context, &property); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not set requested property", error); }
// not part of mysql.h, but needed to access the C fields // typedef char **MYSQL_ROW; static IDL_VPTR IDL_mg_mysql_get_blobfield(int argc, IDL_VPTR *argv) { MYSQL_ROW row = (MYSQL_ROW) argv[0]->value.ptrint; IDL_ULONG field_index = IDL_ULongScalar(argv[1]); unsigned long length = IDL_ULong64Scalar(argv[2]); char *field = row[field_index]; IDL_ARRAY_DIM dims; IDL_VPTR blob; char *blob_data; int i; dims[0] = length; blob_data = (char *) IDL_MakeTempArray(IDL_TYP_BYTE, 1, dims, IDL_ARR_INI_NOP, &blob); for (i = 0; i < length; i++) { blob_data[i] = field[i]; } return blob; }
// // idlpgr_Connect // void IDL_CDECL idlpgr_Connect(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; fc2PGRGuid guid; IDL_MEMINT n; IDL_ULONG *pd; int i; context = (fc2Context) IDL_ULong64Scalar(argv[0]); IDL_ENSURE_ARRAY(argv[1]); if (argv[1]->value.arr->n_elts != 4) IDL_MessageFromBlock(msgs, M_IDLPGR_ERROR, IDL_MSG_LONGJMP, "Provided variable is not a camera GUID."); pd = (IDL_ULONG *) argv[1]->value.arr->data; for (i = 0; i < 4; i++) guid.value[i] = pd[i]; error = fc2Connect(context, &guid); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not connect camera to context", error); }
// int STDCALL mysql_real_query(MYSQL *mysql, const char *q, // unsigned long length); static IDL_VPTR IDL_mg_mysql_real_query(int argc, IDL_VPTR *argv) { int status = mysql_real_query((MYSQL *)argv[0]->value.ptrint, IDL_VarGetString(argv[1]), IDL_ULong64Scalar(argv[2])); return IDL_GettmpLong(status); }