Registriert seit: 2. Feb 2009
Ort: Varel
70 Beiträge
RAD-Studio 2009 Pro
|
AW: Ansprechen einer GigE Kamera (Prosilica GC2450C)
11. Jul 2012, 17:06
So, einige erste Funktionen (wie Initialize und Versionsinfos) bekomme ich inzwischen aus der DLL.
Allerdings sind da noch diverse offene Fragen bezüglich der Übersetzung. Ich habe den C Code:
Delphi-Quellcode:
#define PVDECL __stdcall
typedef void* tPvHandle; // Camera handle
typedef enum
{
ePvErrSuccess = 0, // No error
ePvErrCameraFault = 1, // Unexpected camera fault
ePvErrInternalFault = 2, // Unexpected fault in PvApi or driver
ePvErrBadHandle = 3, // Camera handle is invalid
ePvErrBadParameter = 4, // Bad parameter to API call
ePvErrBadSequence = 5, // Sequence of API calls is incorrect
ePvErrNotFound = 6, // Camera or attribute not found
ePvErrAccessDenied = 7, // Camera cannot be opened in the specified mode
ePvErrUnplugged = 8, // Camera was unplugged
ePvErrInvalidSetup = 9, // Setup is invalid (an attribute is invalid)
ePvErrResources = 10, // System/network resources or memory not available
ePvErrBandwidth = 11, // 1394 bandwidth not available
ePvErrQueueFull = 12, // Too many frames on queue
ePvErrBufferTooSmall= 13, // Frame buffer is too small
ePvErrCancelled = 14, // Frame cancelled by user
ePvErrDataLost = 15, // The data for the frame was lost
ePvErrDataMissing = 16, // Some data in the frame is missing
ePvErrTimeout = 17, // Timeout during wait
ePvErrOutOfRange = 18, // Attribute value is out of the expected range
ePvErrWrongType = 19, // Attribute is not this type (wrong access function)
ePvErrForbidden = 20, // Attribute write forbidden at this time
ePvErrUnavailable = 21, // Attribute is not available at this time
ePvErrFirewall = 22, // A firewall is blocking the traffic (Windows only)
__ePvErr_force_32 = 0xFFFFFFFF
} tPvErr;
typedef enum
{
ePvAccessMonitor = 2, // Monitor access: no control, read & listen only
ePvAccessMaster = 4, // Master access: full control
__ePvAccess_force_32 = 0xFFFFFFFF
} tPvAccessFlags;
typedef struct
{
unsigned long StructVer; // Version of this structure
//---- Version 1 ----
unsigned long UniqueId; // Unique value for each camera
char CameraName[32]; // People-friendly camera name (usually part name)
char ModelName[32]; // Name of camera part
char PartNumber[32]; // Manufacturer's part number
char SerialNumber[32]; // Camera's serial number
char FirmwareVersion[32]; // Camera's firmware version
unsigned long PermittedAccess; // A combination of tPvAccessFlags
unsigned long InterfaceId; // Unique value for each interface or bus
tPvInterface InterfaceType; // Interface type; see tPvInterface
} tPvCameraInfoEx;
unsigned long PVDECL PvCameraListEx(tPvCameraInfoEx* pList,
unsigned long ListLength,
unsigned long* pConnectedNum,
unsigned long StructSize);
tPvErr PVDECL PvCameraOpen(unsigned long UniqueId,
tPvAccessFlags AccessFlag,
tPvHandle* pCamera);
Quasi folgendermassen übersetzt:
Delphi-Quellcode:
{MINENUMSIZE 4} // stimmt diese Größe???
tPvHandle = Pointer;
vErr =
(ePvErrSuccess = 00, // No error
ePvErrCameraFault = 01, // Unexpected camera fault
ePvErrInternalFault = 02, // Unexpected fault in PvApi or driver
ePvErrBadHandle = 03, // Camera handle is invalid
ePvErrBadParameter = 04, // Bad parameter to API call
ePvErrBadSequence = 05, // Sequence of API calls is incorrect
ePvErrNotFound = 06, // Camera or attribute not found
ePvErrAccessDenied = 07, // Camera cannot be opened in the specified mode
ePvErrUnplugged = 08, // Camera was unplugged
ePvErrInvalidSetup = 09, // Setup is invalid (an attribute is invalid)
ePvErrResources = 10, // System/network resources or memory not available
ePvErrBandwidth = 11, // 1394 bandwidth not available
ePvErrQueueFull = 12, // Too many frames on queue
ePvErrBufferTooSmall = 13, // Frame buffer is too small
ePvErrCancelled = 14, // Frame cancelled by user
ePvErrDataLost = 15, // The data for the frame was lost
ePvErrDataMissing = 16, // Some data in the frame is missing
ePvErrTimeout = 17, // Timeout during wait
ePvErrOutOfRange = 18, // Attribute value is out of the expected range
ePvErrWrongType = 19, // Attribute is not this type (wrong access function)
ePvErrForbidden = 20, // Attribute write forbidden at this time
ePvErrUnavailable = 21, // Attribute is not available at this time
ePvErrFirewall = 22, // A firewall is blocking the traffic (Windows only)
__ePvErr_force_32 = $FFFFFFFF
) ;
tPvAccessFlags =
(ePvAccessMonitor = 2, // Monitor access: no control, read & listen only
ePvAccessMaster = 4, // Master access: full control
__ePvAccess_force_32 = $FFFFFFFF
);
tPvCameraInfoEx = Packed Record
StructVer : Cardinal; // Version of this structure
//---- Version 1 ----
UniqueId : Cardinal; // Unique value for each camera
CameraName : Array [0..32] of Char; // People-friendly camera name (usually part name)
ModelName : Array [0..32] of Char; // Name of camera part
PartNumber : Array [0..32] of Char; // Manufacturer's part number
SerialNumber : Array [0..32] of Char; // Camera's serial number
FirmwareVersion : Array [0..32] of Char; // Camera's firmware version
PermittedAccess : Cardinal; // A combination of tPvAccessFlags
InterfaceId : Cardinal; // Unique value for each interface or bus
InterfaceType : tPvInterface; // Interface type; see tPvInterface
end;
Function PvCameraListEx (pList : Array of tPvCameraInfoEx; ListLength : Cardinal; pConnectedNum : Cardinal; Size : Cardinal) : Cardinal; stdcall; external ' PvAPI.dll';
Function PvCameraOpen (UNiqueID : Cardinal; AccessFlag : tPvAccessFlags; pCamera : tPvHandle) : tPvErr; stdcall; external ' PvAPI.dll';
Leider möchte das bereits an dieser frühen Stelle nicht kompilieren. Bin recht zuversichtlich, aber es kommt ja noch die Extraktion der Bilder aus dem Datenstream...
Ich denke, daß Cardinal dem unsigned long entsprechen sollte. Die Frage ist allerdings, ob die Array-Grenzen so richtig sind, ob es tatsächlich ein Packed Record ist und vor allem wie die Pointereien im Aufruf umzusetzen sind. Oder hab ich hier noch ganz andere Fehler drin?
Jan
Aufrufen würde ich das später etwa so:
Delphi-Quellcode:
Var listAVTGigECams : Array [0..20] of tPvCameraInfoEx;
valNumberOfCams : Cardinal;
valAvailableCams : Cardinal;
aHandle : tPvHandle;
begin
valNumberOfCams := PvCameraListEx (listAVTGigECameras, High (listAVTGigECams), valAvailableCameras, SizeOf (tPvCameraInfoEx));
PvCameraOpen (listAVTGigECameras[0].UniqueID, aHandle);
end;
Geändert von BoolString (11. Jul 2012 um 21:07 Uhr)
Grund: Falschen Code im C-Teil reinkopiert
|