add everything from https://storage.kayainstruments.com/s/vision-point except for archived software versions

This commit is contained in:
2024-11-06 23:32:15 -07:00
parent 9693af1bfa
commit c5f05da5e5
228 changed files with 20172 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
1. Vision Point 2019.2 is the latest release to support Windows 7.
2. View release notes before upgrading to Vision Point II.

View File

@@ -0,0 +1,38 @@
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("KYFGLibNET")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("KYFGLibNET")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2017")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];

View File

@@ -0,0 +1,57 @@
#ifndef KYFG_CSHARP_LIB_INTERNAL_H_
#define KYFG_CSHARP_LIB_INTERNAL_H_
#include <string>
#include <map>
//DISABLE_WARNING_PUSH
//DISABLE_WARNING_NEED_DLL_INTERFACE
class EnumParameterDefinition
{
public:
class Entry
{
public:
#ifndef _MSC_VER
// otherwise (g++): error: no matching function for call to EnumParameterDefinition::Entry::Entry(<brace-enclosed initializer list>)
// see https://stackoverflow.com/questions/18184096/c11-struct-initialization-compilation-error: This restriction has been lifted in C++14
Entry(){};
Entry(int64_t _value, const char* _name, const char* _displayName)
:value(_value), name(_name), displayName(_displayName)
{}
#endif
//const
int64_t value = 0;
//const
std::string name;
//const
std::string displayName;
//Entry(int64_t _value, const std::string& _name, const std::string& _displayName)
// :value(_value)
// ,name(_name)
// ,displayName(_displayName)
//{
//
//};
//Entry(const Entry && other)
// :value(other.value)
// ,name(other.name)
// ,displayName(other.displayName)
//{
//
//}
};
/*
*/
std::map<int64_t, Entry> m_Entries;
/*
std::vector<std::unique_ptr<const Entry>> m_Entries;
*/
};
//DISABLE_WARNING_POP
KAYA_API FGSTATUS KY_GetEnumParameterDefinition(KYHANDLE handle, const char* paramName, EnumParameterDefinition &enumParameterDefinition);
#endif // KYFG_CSHARP_LIB_INTERNAL_H_

View File

@@ -0,0 +1,207 @@
// This is the main DLL file.
#include "stdafx.h"
#include <stdint.h>
#include "KYFGLib.NET.h"
#include "KYFGLib_Device.h"
#include "KYFGLib_Camera.h"
#include "KYFGLib_Stream.h"
#include "KYFGLib_StreamBuffer.h"
#include <stdio.h>
#include <vcclr.h>
using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
namespace KAYA
{
// compile with: /doc:DocFileName.xml
Lib::Lib() {}
// TODO: Ask Michael - do we need at this point add support to return the array of PIDs or number of devices is OK?
// If yes, do we need return tuple? There is tuple support since NET 4.0
void Lib::Initialize(InitParameters^ initParameters)
{
::KYFGLib_InitParameters nInitParameters;
nInitParameters.version = initParameters->version;
nInitParameters.concurrency_mode = initParameters->concurrency_mode;
nInitParameters.logging_mode = initParameters->logging_mode;
nInitParameters.noVideoStreamProcess = initParameters->noVideoStreamProcess ? KYTRUE : KYFALSE;
FGSTATUS KYFGLib_Initialize_status = ::KYFGLib_Initialize(&nInitParameters); // Calling native function
if (KYFGLib_Initialize_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFGLib_Initialize_status);
}
}
int Lib::Scan()
{
int detectedDevices = 0;
FGSTATUS KY_DeviceScan_status = ::KY_DeviceScan(&detectedDevices);
if (KY_DeviceScan_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KY_DeviceScan_status);
}
return detectedDevices; // return number of available devices
}
/* The following function has been deprecated. Use call to DeviceInfo(i).DeviceName instead
String^ Lib::DeviceDisplayName(int dev_id)
{
const char* dev_name = ::KY_DeviceDisplayName(dev_id); // Get native Device Name
String^ strNew = gcnew String(dev_name); // Create a managed Device Name
return strNew;
}
*/
DEVICE_INFO^ Lib::DeviceInfo(int dev_index)
{
FGSTATUS KY_DeviceInfo_status;
KY_DEVICE_INFO dev_info_native;
DEVICE_INFO^ dev_info;
dev_info_native.version = 4;
KY_DeviceInfo_status = ::KY_DeviceInfo(dev_index, &dev_info_native);
if (KY_DeviceInfo_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KY_DeviceInfo_status);
}
dev_info = gcnew DEVICE_INFO(dev_info_native.version,
dev_info_native.szDeviceDisplayName,
dev_info_native.nBus,
dev_info_native.nSlot,
dev_info_native.nFunction,
dev_info_native.DevicePID,
dev_info_native.isVirtual,
dev_info_native.m_Flags,
dev_info_native.m_Protocol,
dev_info_native.DeviceGeneration);
return dev_info;
}
SOFTWARE_VERSION^ Lib::GetSoftwareVersion()
{
FGSTATUS KY_GetSoftwareVersion_status;
KY_SOFTWARE_VERSION soft_ver_native;
SOFTWARE_VERSION^ ver_info;
soft_ver_native.struct_version = 2;
KY_GetSoftwareVersion_status = ::KY_GetSoftwareVersion(&soft_ver_native);
if (KY_GetSoftwareVersion_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KY_GetSoftwareVersion_status);
}
ver_info = gcnew SOFTWARE_VERSION(
soft_ver_native.struct_version,
soft_ver_native.Major,
soft_ver_native.Minor,
soft_ver_native.SubMinor,
soft_ver_native.Beta,
soft_ver_native.RC,
soft_ver_native.Alpha);
return ver_info;
}
IDevice^ Lib::Open(int cardID)
{
FGHANDLE fg_handle = ::KYFG_Open(cardID); // Get the native Frame Grabber handle
if (fg_handle == INVALID_FGHANDLE)
{
throw gcnew KYFGLibException(FGSTATUS_UNKNOWN_HANDLE);
}
Device^ fDevice = gcnew Device(fg_handle); // Create a managed Device class from native handle
return fDevice;
}
IDevice^ Lib::OpenEx(int index, const System::String^ projectFile)
{
IntPtr p = Marshal::StringToHGlobalAnsi((System::String^)projectFile); // Get native char* path to file
const char* projectFile_native_str = (const char*) (p.ToPointer());
FGHANDLE fg_handle = ::KYFG_OpenEx(index, projectFile_native_str); // Get the native Frame Grabber handle
if (fg_handle == INVALID_FGHANDLE)
{
throw gcnew KYFGLibException(FGSTATUS_UNKNOWN_HANDLE);
}
Device^ fDevice = gcnew Device(fg_handle); // Create a managed Grabber class from native handle
return fDevice;
}
IDevice^ Lib::OpenEx(int index)
{
return Lib::OpenEx(index,nullptr);
}
DEVICE_EVENT_CAMERA_START::DEVICE_EVENT_CAMERA_START(KYDEVICE_EVENT_CAMERA_START* unmanagedDeviceEventCameraStart)
{
DeviceEvent = gcnew DEVICE_EVENT(&(unmanagedDeviceEventCameraStart->deviceEvent));
CamObj = gcnew Camera(unmanagedDeviceEventCameraStart->camHandle);
}
DEVICE_EVENT_CAMERA_CONNECTION_LOST::DEVICE_EVENT_CAMERA_CONNECTION_LOST(KYDEVICE_EVENT_CAMERA_CONNECTION_LOST* unmanagedDeviceEvent)
{
DeviceEvent = gcnew DEVICE_EVENT(&(unmanagedDeviceEvent->deviceEvent));
CamObj = gcnew Camera(unmanagedDeviceEvent->camHandle);
DeviceLink = gcnew System::UInt64(unmanagedDeviceEvent->iDeviceLink);
CameraLink = gcnew System::UInt64(unmanagedDeviceEvent->iCameraLink);
}
DEVICE_EVENT_SYSTEM_TEMPERATURE::DEVICE_EVENT_SYSTEM_TEMPERATURE(KYDEVICE_EVENT_SYSTEM_TEMPERATURE* unmanagedDeviceTemperatureEvent)
{
DeviceEvent = gcnew DEVICE_EVENT(&(unmanagedDeviceTemperatureEvent->deviceEvent));
temperatureThresholdId = KYDEVICE_EVENT_SYSTEM_TEMPERATURE_THRESHOLD_ID(unmanagedDeviceTemperatureEvent->temperatureThresholdId);
}
DEVICE_EVENT_CXP2_HEARTBEAT::DEVICE_EVENT_CXP2_HEARTBEAT(KYDEVICE_EVENT_CXP2_HEARTBEAT* unmanagedDeviceCXP2HeartbeatEvent)
{
DeviceEvent = gcnew DEVICE_EVENT(&(unmanagedDeviceCXP2HeartbeatEvent->deviceEvent));
CamObj = gcnew Camera(unmanagedDeviceCXP2HeartbeatEvent->camHandle);
heartBeat = gcnew CXP2_HEARTBEAT(unmanagedDeviceCXP2HeartbeatEvent->heartBeat.masterHostConnectionID,
unmanagedDeviceCXP2HeartbeatEvent->heartBeat.cameraTime);
}
DEVICE_EVENT_CXP2_EVENT::DEVICE_EVENT_CXP2_EVENT(KYDEVICE_EVENT_CXP2_EVENT* unmanagedDeviceCXP2EventEvent)
{
DeviceEvent = gcnew DEVICE_EVENT(&(unmanagedDeviceCXP2EventEvent->deviceEvent));
CamObj = gcnew Camera(unmanagedDeviceCXP2EventEvent->camHandle);
cxp2Event = gcnew CXP2_EVENT(unmanagedDeviceCXP2EventEvent->cxp2Event.masterHostConnectionID,
unmanagedDeviceCXP2EventEvent->cxp2Event.tag,
unmanagedDeviceCXP2EventEvent->cxp2Event.dataSize,
unmanagedDeviceCXP2EventEvent->cxp2Event.dataWords);
}
DEVICE_EVENT_GENCP_EVENT::DEVICE_EVENT_GENCP_EVENT(KYDEVICE_EVENT_GENCP_EVENT* unmanagedDeviceGencpEvent)
{
DeviceEvent = gcnew DEVICE_EVENT(&(unmanagedDeviceGencpEvent->deviceEvent));
srcDevicePort = gcnew System::Int32(unmanagedDeviceGencpEvent->srcDevicePort);
gencpEvent = gcnew GENCP_EVENT(unmanagedDeviceGencpEvent->gencpEvent.eventSize,
unmanagedDeviceGencpEvent->gencpEvent.eventId,
unmanagedDeviceGencpEvent->gencpEvent.timestamp,
unmanagedDeviceGencpEvent->gencpEvent.data);
}
DEVICE_EVENT_GIGE_EVENTDATA::DEVICE_EVENT_GIGE_EVENTDATA(KYDEVICE_EVENT_GIGE_EVENTDATA* unmanagedDeviceGigeEvent)
{
DeviceEvent = gcnew DEVICE_EVENT(&(unmanagedDeviceGigeEvent->deviceEvent));
srcDevicePort = gcnew System::Int32(unmanagedDeviceGigeEvent->srcDevicePort);
gigeEvent = gcnew GIGE_EVENTDATA_EVENT(unmanagedDeviceGigeEvent->gigeEvent.eventSize,
unmanagedDeviceGigeEvent->gigeEvent.eventId,
unmanagedDeviceGigeEvent->gigeEvent.streamChannel,
unmanagedDeviceGigeEvent->gigeEvent.blockId,
unmanagedDeviceGigeEvent->gigeEvent.timestamp,
unmanagedDeviceGigeEvent->gigeEvent.data);
}
}

View File

@@ -0,0 +1,984 @@
// KYFGLib.NET.h
#pragma once
#include "KYFGLib.h"
// #include "KYBase.hpp" // uncomment this after solving all CLR errors
#define KY_NEW new
#define KY_NEW_ARRAY new
//public class EnumParameterDefinition;
#pragma managed(push, off)
#include "Internal/KYFGcsharpLib_internal.h"
//#include "Internal/KYFGcppLib_internal.h" // TODO This causes Error C1189 #error: <mutex> is not supported when compiling with /clr or /clr:pure. KYFGLib.NET c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\mutex 8
#pragma managed(pop)
namespace KAYA
{
interface class IParameters;
interface class IDevice;
interface class ICamera;
interface class IStream;
interface class IStreamBuffer;
ref class AuxData;
ref class Camera;
public delegate void StreamBufferCallback(IStreamBuffer^, System::Object^);
public delegate void InternalStreamBufferCallback(STREAM_BUFFER_HANDLE, void*);
public delegate void FGAuxDataCallback(AuxData^, System::Object^);
public delegate void InternalFGAuxDataCallback(KYFG_AUX_DATA* pData, void* context);
public delegate void CameraCallback(System::Object^, IStream^ );
public delegate void InternalCameraCallback(void* context, STREAM_HANDLE stream_handle);
public delegate void DeviceEventCallBack(System::Object^, System::Object^);
public delegate void InternalDeviceEventCallBack(void*, KYDEVICE_EVENT*);
/* Implementation Of Managed EVENT enums */
public enum class KYDEVICE_EVENT_ID
{
DEVICE_EVENT_CAMERA_START_REQUEST = ::KYDEVICE_EVENT_CAMERA_START_REQUEST,
DEVICE_EVENT_CAMERA_CONNECTION_LOST_ID = ::KYDEVICE_EVENT_CAMERA_CONNECTION_LOST_ID,
DEVICE_EVENT_SYSTEM_TEMPERATURE_ID = ::KYDEVICE_EVENT_SYSTEM_TEMPERATURE_ID,
DEVICE_EVENT_CXP2_HEARTBEAT_ID = ::KYDEVICE_EVENT_CXP2_HEARTBEAT_ID,
DEVICE_EVENT_CXP2_EVENT_ID = ::KYDEVICE_EVENT_CXP2_EVENT_ID,
DEVICE_EVENT_GENCP_EVENT_ID = ::KYDEVICE_EVENT_GENCP_EVENT_ID,
DEVICE_EVENT_GIGE_EVENTDATA_ID = ::KYDEVICE_EVENT_GIGE_EVENTDATA_ID
};
/* END OF KYDEVICE_EVENT_ID */
public enum class KYDEVICE_EVENT_SYSTEM_TEMPERATURE_THRESHOLD_ID
{
DEVICE_EVENT_SYSTEM_TEMPERATURE_NORMAL = ::KYDEVICE_EVENT_SYSTEM_TEMPERATURE_NORMAL,
DEVICE_EVENT_SYSTEM_TEMPERATURE_WARNING = ::KYDEVICE_EVENT_SYSTEM_TEMPERATURE_WARNING,
DEVICE_EVENT_SYSTEM_TEMPERATURE_CRITICAL = ::KYDEVICE_EVENT_SYSTEM_TEMPERATURE_CRITICAL
};
/* Implementation Of Managed KY_STREAM_INFO_CMD */
public enum class KY_STREAM_INFO_CMD
{
KY_STREAM_INFO_PAYLOAD_SIZE = ::KY_STREAM_INFO_PAYLOAD_SIZE, // Size of the expected data in bytes, of currently configured stream
KY_STREAM_INFO_BUF_ALIGNMENT = ::KY_STREAM_INFO_BUF_ALIGNMENT, // Buffer memory alignment in bytes
KY_STREAM_INFO_PAYLOAD_SIZE_INCREMENT_FACTOR = ::KY_STREAM_INFO_PAYLOAD_SIZE_INCREMENT_FACTOR, // Payload size should be divisible by increment factor
KY_STREAM_INFO_ACTUAL_PAYLOAD_SIZE = ::KY_STREAM_INFO_ACTUAL_PAYLOAD_SIZE, // Size of the actual data in bytes that will be delivered, for current device configurations(change every update of parameters which define the image dimensions)
KY_STREAM_INFO_BUF_COUNT = ::KY_STREAM_INFO_BUF_COUNT, // Number of buffers in the stream
KY_STREAM_INFO_INSTANTFPS = ::KY_STREAM_INFO_INSTANTFPS, // Last calculated FPS.Valid after at least two frames have been acquired
KY_STREAM_INFO_CAMHANDLE =::KY_STREAM_INFO_CAMHANDLE // CAMHANDLE of the camera to which this stream belongs.May be NULL_CAMHANDLE
// in future enhancements with multi - camera streams
};
/* END OF KY_STREAM_INFO_CMD */
/* Implementation Of Managed KY_STREAM_BUFFER_INFO_CMD */
public enum class KY_STREAM_BUFFER_INFO_CMD
{
KY_STREAM_BUFFER_INFO_BASE = ::KY_STREAM_BUFFER_INFO_BASE, // PTR Base address of the buffer memory
KY_STREAM_BUFFER_INFO_SIZE = ::KY_STREAM_BUFFER_INFO_SIZE, // SIZET Size of the buffer in bytes
KY_STREAM_BUFFER_INFO_USER_PTR = ::KY_STREAM_BUFFER_INFO_USER_PTR, // PTR Private data pointer for the stream buffer
KY_STREAM_BUFFER_INFO_TIMESTAMP = ::KY_STREAM_BUFFER_INFO_TIMESTAMP, // UINT64 Timestamp the buffer was acquired
KY_STREAM_BUFFER_INFO_INSTANTFPS = ::KY_STREAM_BUFFER_INFO_INSTANTFPS, // FLOAT64 Instant FPS calculated from current and previous timestamp
KY_STREAM_BUFFER_INFO_IMAGEID = ::KY_STREAM_BUFFER_INFO_IMAGEID, // UINT64 Image ID as reported by a transport protocol, e.g. CXP's "source image index"
KY_STREAM_BUFFER_INFO_ID = ::KY_STREAM_BUFFER_INFO_ID, // UINT32 Unique id of buffer in the stream
KY_STREAM_BUFFER_INFO_STREAM_HANDLE = ::KY_STREAM_BUFFER_INFO_STREAM_HANDLE //STREAM_HANDLE the handle of a stream to which this buffer belongs
};
/* END OF Implementation Of Managed KY_STREAM_BUFFER_INFO_CMD */
static const int KY_MAX_CAMERAS = ::KY_MAX_CAMERAS;
static const int KY_MAX_CAMERA_INFO_STRING_SIZE = ::KY_MAX_CAMERA_INFO_STRING_SIZE;
/* Implementation Of Managed KY_ACQ_QUEUE_TYPE */
public enum class KY_ACQ_QUEUE_TYPE
{
KY_ACQ_QUEUE_INPUT, // buffers in INPUT queue are ready to be filled with data
KY_ACQ_QUEUE_OUTPUT, // buffers in OUTPUT queue have been filled and awaiting user processing
KY_ACQ_QUEUE_UNQUEUED, // buffers in UNQUEUED set have been anounced but are inactive for acquisition mechanisem. By default all buffers are placed in UNQUEUED set
KY_ACQ_QUEUE_AUTO, // buffers in AUTO queue are managed automatically, in a cyclic matter, without the need for user to re-queue them
};
/* End Of Implementation Of Managed KY_ACQ_QUEUE_TYPE */
public enum class KYBOOL
{
KY_TRUE = 1,
KY_FALSE = 0,
};
public ref class InitParameters
{
public:
System::UInt32 version; // Version of this structure definition, must be not 0 and less than 3
// since version 1:
System::UInt32 concurrency_mode; // combination of KYFGLIB_CONCURRENCY_FLAGS, all unused bits must be set to 0
System::UInt32 logging_mode; // reserved, must be set to 0
// since version 2:
System::Boolean noVideoStreamProcess; // Use library without requesting video stream facilities, e.g for camera control only
InitParameters() :
version(0), concurrency_mode(0), logging_mode(0), noVideoStreamProcess(false)
{
}
};
public enum class KY_DEVICE_PROTOCOL
{
KY_DEVICE_PROTOCOL_CoaXPress = ::KY_DEVICE_PROTOCOL_CoaXPress,
KY_DEVICE_PROTOCOL_CLHS = ::KY_DEVICE_PROTOCOL_CLHS,
KY_DEVICE_PROTOCOL_GigE = ::KY_DEVICE_PROTOCOL_GigE,
KY_DEVICE_PROTOCOL_Mixed = ::KY_DEVICE_PROTOCOL_Mixed,
KY_DEVICE_PROTOCOL_Unknown = ::KY_DEVICE_PROTOCOL_Unknown
};
public enum class PORT_STATUS
{
PORT_DISCONNECTED = ::PORT_DISCONNECTED, // the port is disconnected, no link has been established
PORT_SYNCHRONIZED = ::PORT_SYNCHRONIZED, // port link is synchronized and awaiting connection
PORT_CONNECTING = ::PORT_CONNECTING, // a connection is trying to be established on port
PORT_CONNECTED = ::PORT_CONNECTED // port is connected and assigned to camera
};
public enum class SUBMIT_BUFF_FLAGS
{
SUBMIT_BUFF_REGULAR_BUFFER = ::SUBMIT_BUFF_REGULAR_BUFFER,
SUBMIT_BUFF_PHYSICAL_ADDRESS = ::SUBMIT_BUFF_PHYSICAL_ADDRESS, // provided buffer addresses are physical addresses
};
public ref class DEVICE_INFO
{
public:
System::UInt32^ Version;
// since version 1:
System::String^ DeviceName;
System::Int32^ Bus;
System::Int32^ Slot;
System::Int32^ Function;
System::UInt32^ DevicePID;
System::Boolean^ isVirtual;
// since version 2:
System::UInt16 Flags; // mask KY_DEVICE_STREAM_GRABBER indicates device that supports grabbing (input streams).
// mask KY_DEVICE_STREAM_GENERATOR indicates device that supports generation (output streams).
// since version 3:
KY_DEVICE_PROTOCOL Protocol;
// since version 4:
System::UInt32 DeviceGeneration; // 1 or 2 (I or II)
DEVICE_INFO(uint32_t nVersion, char* device_name_native, int nBus, int nSlot, int nFunction, uint32_t nDevicePID, ::KYBOOL nisVirtual, uint8_t m_Flags,
::KY_DEVICE_PROTOCOL m_Protocol, uint32_t DeviceGeneration) : Version(nVersion), Bus(nBus), Slot(nSlot), Function(nFunction), DevicePID(nDevicePID),
Flags(m_Flags), DeviceGeneration(DeviceGeneration)
{
DeviceName = gcnew System::String(device_name_native);
isVirtual = (nisVirtual == KYTRUE) ? true : false;
switch (m_Protocol)
{
case ::KY_DEVICE_PROTOCOL_CoaXPress :
Protocol = KY_DEVICE_PROTOCOL::KY_DEVICE_PROTOCOL_CoaXPress;
break;
case ::KY_DEVICE_PROTOCOL_CLHS:
Protocol = KY_DEVICE_PROTOCOL::KY_DEVICE_PROTOCOL_CLHS;
break;
case ::KY_DEVICE_PROTOCOL_GigE:
Protocol = KY_DEVICE_PROTOCOL::KY_DEVICE_PROTOCOL_GigE;
break;
case ::KY_DEVICE_PROTOCOL_Mixed:
Protocol = KY_DEVICE_PROTOCOL::KY_DEVICE_PROTOCOL_Mixed;
break;
case ::KY_DEVICE_PROTOCOL_Unknown:
Protocol = KY_DEVICE_PROTOCOL::KY_DEVICE_PROTOCOL_Unknown;
break;
default:
break;
}
}
};
public ref class SOFTWARE_VERSION
{
public:
System::UInt16^ Reserved;
System::UInt16^ Major;
System::UInt16^ Minor;
System::UInt16^ SubMinor;
System::UInt16^ Beta;
System::UInt16^ RC;
System::UInt16^ Alpha;
SOFTWARE_VERSION(uint16_t nReserved, uint16_t nMajor, uint16_t nMinor, uint16_t nSubMinor, uint16_t nBeta, uint16_t nRC, uint16_t nAlpha) :
Reserved(nReserved), Major(nMajor), Minor(nMinor), SubMinor(nSubMinor), Beta(nBeta), RC(nRC), Alpha(nAlpha)
{}
};
public ref class CAMERA_INFO
{
public:
const System::Byte^ master_link;
const System::Byte^ link_mask;
System::Int32^ link_speed;
System::UInt32^ stream_id;
System::String^ deviceVersion;
System::String^ deviceVendorName;
System::String^ deviceManufacturerInfo;
System::String^ deviceModelName;
System::String^ deviceID;
System::String^ deviceUserID;
System::Boolean^ outputCamera;
System::Boolean^ virtualCamera;
System::String^ deviceFirmwareVersion;
CAMERA_INFO(unsigned char master_link_nat, unsigned char link_mask_nat, ::CXP_LINK_SPEED link_speed_nat, uint32_t stream_id_nat, char* deviceVersion_nat, char* deviceVendorName_nat,
char* deviceManufacturerInfo_nat, char* deviceModelName_nat, char* deviceID_nat, char* deviceUserID_nat, ::KYBOOL outputCamera_nat, ::KYBOOL virtualCamera_nat, char* deviceFirmwareVersion_nat)
{
master_link = gcnew System::Byte(master_link_nat);
link_mask = gcnew System::Byte(link_mask_nat);
link_speed = gcnew System::Int32(link_speed_nat);
stream_id = gcnew System::UInt32(stream_id_nat);
deviceVersion = gcnew System::String(deviceVersion_nat);
deviceVendorName = gcnew System::String(deviceVendorName_nat);
deviceManufacturerInfo = gcnew System::String(deviceManufacturerInfo_nat);
deviceModelName = gcnew System::String(deviceModelName_nat);
deviceID = gcnew System::String(deviceID_nat);
deviceUserID = gcnew System::String(deviceUserID_nat);
outputCamera = gcnew System::Boolean(outputCamera_nat);
virtualCamera = gcnew System::Boolean(virtualCamera_nat);
deviceFirmwareVersion = gcnew System::String(deviceFirmwareVersion_nat);
}
};
public interface class IParameters
{
public:
/// <summary>
/// Set parameter value.
/// </summary>
/// <param name='paramName'>Name of configuration parameter</param>
/// <param name='paramValue'>Object, that represents a param value corresponding to the param name. Can be Boolean, String, Float, Int64 or a Enum</param>
virtual void SetValue(const System::String^ paramName, Object^ paramValue);
/// <summary>
/// Set camera/Frame Grabber configuration enumeration field by field name and enumeration name, according to Gen<i>Cam standard naming and xml field definition and type.
/// </summary>
/// <param name='paramName'>Name of configuration parameter</param>
/// <param name='paramName'>Name of parameter enumeration choice</param>
virtual void SetValueEnum_ByValueName(const System::String^ paramName, const System::String^ param);
/// <summary>
/// Get parameter value.
/// </summary>
/// <param name='paramName'>Name of configuration parameter</param>
/// <returns>Object, that represents a param value corresponding to the param name. Can be Boolean, String, Float, Int64 or a Enum<</returns>
virtual Object^ GetValue(const System::String^ paramName);
/// <summary>
/// Get parameter min, max values integer type.
/// </summary>
/// <param name='paramName'>Name of configuration parameter</param>
/// <returns>Object, that represents a param min, max values corresponding to the param name.<</returns>
virtual Object^ GetValueIntMaxMin(const System::String^ paramName);
/// <summary>
/// Get parameter min, max values float type.
/// </summary>
/// <param name='paramName'>Name of configuration parameter</param>
/// <returns>Object, that represents a param min, max values corresponding to the param name.<</returns>
virtual Object^ GetValueFloatMaxMin(const System::String^ paramName);
/// <summary>
/// Execute command; applicable for values of Command type. According to Gen<i>Cam standard naming and xml field definition and type.
/// </summary>
/// <param name='paramName'>Name of configuration parameter</param>
virtual void ExecuteCommand(const System::String^ paramName);
};
public interface class IDevice : public IParameters
{
public:
/// <summary>
/// The Frame Grabber scans for connected cameras, establishes connection and defines the default speed for each camera, on every connected channel.
/// </summary>
/// <returns>List of connected cameras</returns>
[System::ObsoleteAttribute("The method 'CameraScan' is a deprecated, please use method 'UpdateCameraList'")]
System::Collections::Generic::List<ICamera^>^ CameraScan();
/// <summary>
/// The Frame Grabber updates the connected cameras, establishes connection and defines the default speed for each camera, on every connected channel.
/// </summary>
/// <returns>List of connected cameras</returns>
System::Collections::Generic::List<ICamera^>^ UpdateCameraList();
/// <summary>
/// Close Frame Grabber specified by its handle. Stops data acquisition of all opened cameras, disconnects from all connected cameras and deletes previously created buffers associated with these cameras.
/// </summary>
void Close();
/// <summary>
/// Write buffer of specified size to specific port. This function access the link directly disregarding the camera connection topology.
/// </summary>
/// <param name='port'>Frame Grabber port index</param>
/// <param name='address'>Start address of the data to write</param>
/// <param name='buffer'>Buffer data to write</param>
void WritePortBlock(int port, System::UInt64 address, array<System::Byte>^ buffer);
/// <summary>
/// Write bootstrap registers from specific port, 32bit value each time. This function access the link directly disregarding the camera connection topology.
/// </summary>
/// <param name='port'>Frame Grabber port index</param>
/// <param name='address'>Address of the register</param>
/// <param name='data'>Bootstrap registers value</param>
void WritePortReg(int port, System::UInt64 address, System::UInt32 data);
/// <summary>
/// Read buffer of specified size from specific port. This function access the link directly disregarding the camera connection topology.
/// </summary>
/// <param name='port'>Frame Grabber port index</param>
/// <param name='address'>Start address of the data to read</param>
/// <param name='size'>Size in bytes of buffer to read</param>
/// <returns>The received data from the port</returns>
array<System::Byte>^ ReadPortBlock(int port, System::UInt64 address, System::UInt32 size);
/// <summary>
/// Read bootstrap registers from specific port, 32bit value each time. This function access the link directly disregarding the camera connection topology.
/// </summary>
/// <param name='port'>Frame Grabber port index</param>
/// <param name='address'>Address of the register</param>
/// <returns>The received data from the register</returns>
System::UInt32 ReadPortReg(int port, System::UInt64 address);
/// <summary>
/// Status of specific device physical port regarding connectivity with remote device(i.e camera)
/// </summary>
/// <param name='port'>Frame Grabber port index</param>
/// <returns>The status of the port</returns>
PORT_STATUS GetPortStatus(int port);
/// <summary>
/// Program provided key to the grabber.
/// </summary>
/// <param name='key'>A key to be programmed into Frame Grabber</param>
/// <param name='lock'>If this parameter is 0 the grabber can be re-programmed with a different key later. If this parameter is 1 then provided key is locked in the Frame Grabber and following call of this function will fail.</param>
void AuthProgramKey(array<System::Byte>^ key, int lock);
/// <summary>
/// Verify provided key against one already programmed to the grabber.
/// </summary>
/// <param name='key'>A key to be verified with Frame Grabber</param>
/// <returns>1 <20> if the key accepted, 0 - otherwise</returns>
int AuthVerify(array<System::Byte>^ key);
/// <summary>
/// Register run-time callback for receiving auxiliary data. The callback will be called when various auxiliary data is generated.
/// </summary>
/// <param name='delegator'>Callback delegate function</param>
/// <param name='userContext'>(optional) User context. Afterwards this pointer is retrieved when the callback is issued. Helps to determine the origin of function call in host application.</param>
void AuxDataCallbackRegister(FGAuxDataCallback^ delegator, Object^ userContext);
/// <summary>
/// Register run-time callback for receiving auxiliary data. The callback will be called when various auxiliary data is generated.
/// </summary>
/// <param name='delegator'>Callback delegate function</param>
void AuxDataCallbackRegister(FGAuxDataCallback^ delegator);
/// <summary>
/// Unregister run-time auxiliary data callback.
/// </summary>
/// <param name='delegator'>Callback delegate function</param>
void AuxDataCallbackUnregister(FGAuxDataCallback^ delegator);
/// <summary>
/// Register Event Callback
/// </summary>
/// <param name='deviceEventDelegator'>Callback delegate function</param>
/// <param name='userContext'>User Context</param>
void EventCallBackRegister(DeviceEventCallBack^ deviceEventDelegator, Object^ userContext);
/// <summary>
/// Register Event Callback with no user context
/// </summary>
/// <param name='deviceEventDelegator'>Callback delegate function</param>
void EventCallBackRegister(DeviceEventCallBack^ deviceEventDelegator);
/// <summary>
/// Unregister Event Callback
/// </summary>
/// <param name='deviceEventDelegator'>Callback delegate function</param>
void EventCallBackUnregister(DeviceEventCallBack^ deviceEventDelegator);
/// <summary>
/// Send Event Message as specified by GenCP for CLHS, or EVENTDATA message for 10GigE
/// Event message from remote device can be received using "KYDeviceEventCallBackRegister" event id "KYDEVICE_EVENT_GENCP_EVENT_ID" for CLHS,
/// and "KYDEVICE_EVENT_GIGE_EVENTDATA_ID" for 10GigE
/// </summary>
void DevicePortSendEventMessage(int port, System::UInt32 eventId, array<System::Byte>^ buffer);
};
public interface class ICamera : public IParameters
{
public:
/// <summary>
/// Retrieve info about camera
/// </summary>
/// <param name='dev_id'>discovered device index</param>
/// <returns>Device's name</returns>
CAMERA_INFO^ CameraInfo();
/// <summary>
/// Opens a connection to chosen camera, retrieves native XML file or uses external XML file provided to override the native one.
/// </summary>
/// <param name='xml_file_path'>Path to override XML file. If NULL, the native XML file from the camera will be retrieved.</param>
void Open(System::String^ xml_file_path);
/// <summary>
/// Close a connection to the selected camera. Stops data acquisition and deletes previously created buffers associated with the camera. The connection information is preserved, so a new connection can be established later.
/// </summary>
void Close();
/// <summary>
/// Starts transmission for the chosen camera. The chosen stream would be filled with data from the camera. Only 1 stream can be active at a time, per camera. Number of frames to be acquired may be set, while 0 frames indicate continues acquisition mode.
/// </summary>
/// <param name='streamHandle'>API handle to data stream for selected camera</param>
/// <param name='frames'>Number of frames to be acquired. After the specified number of frames were acquired, the camera would be stopped. 0 for continues acquisition mode.</param>
void Start(IStream^ streamHandle, int frames);
/// <summary>
/// Stops transmission for the chosen camera.
/// </summary>
void Stop();
/// <summary>
/// A new stream will be allocated for specified camera. The created stream buffers will hold the data of acquired frames. Stream buffer acquisition mechanism and buffer size calculations are handled internally. Buffer frame size is calculated with consideration of specified number of frames, in addition to camera and grabber configuration parameters set previously to this function call. Changing certain camera/grabber parameters, after successfully stream allocation, might result in unstable software operation, memory leaks and even total system crash.
/// </summary>
/// <param name='frames'>Number of frames that should be allocated for this stream.</param>
/// <returns>IStream handle of newly created stream</returns>
IStream^ StreamCreateAndAlloc(int frames);
/// <summary>
/// A new stream will be created for the chosen camera. The stream will manage frame buffers allocated either by user or by library. Frame buffers will be organized in queues <20> input, output, automatic <20> and in a set of unqueued frame buffers
/// </summary>
/// <returns>IStream handle of newly created stream</returns>
IStream^ StreamCreate();
/// <summary>
/// Link all announced frame buffers into a stream to form continuous cyclic buffer
/// </summary>
/// <returns>IStream handle of newly created stream</returns>
void StreamLinkFramesContinuously(IStream^ streamHandle);
/// <summary>
/// Extracts native XML file from chosen camera and fills user allocated buffer. The size (in bytes) and file type (.xml or .zip) are also retrieved even if buffer isn<73>t large enough to hold all file data.
/// </summary>
/// <returns>Tuple(xml_managed_string, isZip_managed), where: xml_managed_string - Byte array, which contains the required XML, isZip_managed - KY_TRUE if the XML archived within Zip, KY_FALSE otherwise</returns>
System::Tuple<array<System::Byte>^, KYBOOL>^ GetXML();
/// <summary>
/// Direct write data buffer to the selected camera.
/// </summary>
/// <param name='address'>Start address of the data to write</param>
/// <param name='buffer'>Buffer data to write</param>
/// <returns>Size of written bytes</returns>
System::UInt32 WriteReg(System::UInt64 address, array<System::Byte>^ buffer);
/// <summary>
/// Direct write data buffer to the selected camera.
/// </summary>
/// <param name='address'>Start address of the data to read</param>
/// <param name='size'>Size in bytes of buffer to read</param>
/// <returns>Buffer that will hold read data</returns>
array<System::Byte>^ ReadReg(System::UInt64 address, System::UInt32 size);
/// <summary>
/// Register a camera runtime acquisition callback function.
/// </summary>
/// <param name='delegator'>Delegator to callback function</param>
/// <param name='userContext'>User defined context to identify the received callback</param>
void CameraCallbackRegister(CameraCallback^ delegator, Object^ userContext);
/// <summary>
/// Register a camera runtime acquisition callback function.
/// </summary>
/// <param name='delegator'>Delegator to callback function</param>
void CameraCallbackRegister(CameraCallback^ delegator);
/// <summary>
/// Unregister a camera runtime acquisition callback function.
/// </summary>
/// <param name='delegator'>Delegator to callback function</param>
void CameraCallbackUnregister(CameraCallback^ delegator);
/// <summary>
/// Send Event Message as specified by GenCP for CLHS, or EVENTDATA message for 10GigE
/// Event message from remote device can be received using "KYDeviceEventCallBackRegister" event id "KYDEVICE_EVENT_GENCP_EVENT_ID" for CLHS,
/// and "KYDEVICE_EVENT_GIGE_EVENTDATA_ID" for 10GigE
/// </summary>
/// <param name='eventId'>id of the event message</param>
/// <param name='buffer'>buffer data to write</param>
void CameraSendEventMessage(System::UInt32 eventId, array<System::Byte>^ buffer);
};
public interface class IStream
{
public:
/// <summary>
/// Register a stream runtime acquisition callback function. The callback (userFunc) will be called upon new received frame, of a valid stream.
/// </summary>
/// <param name='delegator'>Delegator to callback function</param>
/// <param name='userContext'>User defined context to identify the received callback</param>
void BufferCallbackRegister(StreamBufferCallback^ delegator, Object^ userContext);
/// <summary>
/// Register a stream runtime acquisition callback function. The callback (userFunc) will be called upon new received frame, of a valid stream.
/// </summary>
/// <param name='delegator'>Delegator to callback function</param>
void BufferCallbackRegister(StreamBufferCallback^ delegator);
/// <summary>
/// Unregister a camera runtime acquisition callback function.
/// </summary>
/// <param name='delegator'>Delegstor to callback function</param>
void BufferCallbackUnregister(StreamBufferCallback^ delegator);
/* TODO: Check with Michael we dont have to impement this function
System::Int64 GetSize(); */
/* TODO: Check with Michael we dont have to impement this function
int GetFrameIndex(); */
/// <summary>
/// Retrieves a pointer to data memory space of 1 frame in the chosen buffer
/// </summary>
/// <param name='buffIndex'>Frame index of data pointer to be retrieved</param>
/// <returns>Pointer to required buffer</returns>
Object^ GetPtr(System::UInt32 buffIndex);
/// <summary>
/// Deletes a stream. Any memory allocated by user is NOT freed by this function. All memory allocated by library is freed and all API handles bound to the stream became invalid.
/// </summary>
/// <returns>Pointer to required frame</returns>
void Delete();
/// <summary>
/// Retrieves information about specified stream.
/// </summary>
/// <param name='info'>Specifies what information is being requested.
/// Possible values are: KY_STREAM_INFO_PAYLOAD_SIZE, KY_STREAM_INFO_BUF_ALIGNMENT,
/// KY_STREAM_INFO_PAYLOAD_SIZE_INCREMENT_FACTOR, KY_STREAM_INFO_BUF_COUNT, KY_STREAM_INFO_INSTANTFPS, KY_STREAM_INFO_CAMHANDLE</param>
/// <returns>Required Info</returns>
Object^ GetInfo(KY_STREAM_INFO_CMD info);
/// <summary>
/// Retrieves Auxiliary data of specified frame.
/// </summary>
/// <param name='frame'>Frame index to be retrieved</param>
/// <returns>AuxData of specified frame</returns>
AuxData^ GetAux(int frame);
/// <summary>
/// This function is used to allocate and announce a buffer and bind it to a stream.
/// </summary>
/// <param name='nBufferSize'>The size of allocated memory.</param>
/// <returns>Allocated Stream Buffer</returns>
IStreamBuffer^ BufferAllocAndAnnounce(System::UInt64 nBufferSize);
/// <summary>
/// Deprecated !!! This function is used to announce a buffer allocated by user and bind it to a stream. !!! Deprecated
/// </summary>
/// <param name='pBuffer'>User allocated byte array, which will be used to hold frame data</param>
/// <returns>Stream Buffer</returns>
[System::ObsoleteAttribute("The method 'BufferAnnounce' with 'byte[]' is a deprecated, please use method with 'IntPtr'")]
IStreamBuffer^ BufferAnnounce(array<System::Byte>^ pBuffer);
/// <summary>
/// This function is used to announce a buffer allocated by user and bind it to a stream.
/// </summary>
/// <param name='pBuffer'>User allocated aligned IntPtr, which will be used to hold frame data</param>
/// <returns>Stream Buffer</returns>
IStreamBuffer^ BufferAnnounce(System::IntPtr pBuffer, System::UInt64 size);
/// <summary>
/// Revoke and delete resources of previously announced buffer. The buffer should be announced to 'streamHandle' stream, acquisition should be stopped,
/// </summary>
/// <param name='streamBufferHandle'> Handle of previously announced buffer</param>
void BufferRevoke(STREAM_BUFFER_HANDLE streamBufferHandle);
/// <summary>
/// Moves all frame buffers bound to specified stream from one queue to another queue.
/// </summary>
/// <param name='srcQueue'>Source queue</param>
/// <param name='dstQueue'>Destination queue</param>
void BufferQueueAll(KY_ACQ_QUEUE_TYPE srcQueue, KY_ACQ_QUEUE_TYPE dstQueue);
};
public interface class IStreamBuffer
{
public:
/// <summary>
/// Retrieves the index of the current buffer (frame)
/// </summary>
/// <returns>Index of the current buffer</returns>
int GetFrameIndex();
/// <summary>
/// Retrieves a pointer to data memory space of the current buffer (frame).
/// </summary>
/// <returns>Pointer to current buffer (frame)</returns>
Object^ GetPtr();
/// <summary>
/// Retrieves information about previously announced buffer (frame).
/// </summary>
/// <param name='info'>Specifies what information is being requested. Possible values are: KY_STREAM_BUFFER_INFO_BASE, KY_STREAM_BUFFER_INFO_SIZE, KY_STREAM_BUFFER_INFO_USER_PTR, KY_STREAM_BUFFER_INFO_TIMESTAMP, KY_STREAM_BUFFER_INFO_INSTANTFPS, KY_STREAM_BUFFER_INFO_IMAGEID, KY_STREAM_BUFFER_INFO_ID, KY_STREAM_BUFFER_INFO_STREAM_HANDLE</param>
/// <returns>The required Info</returns>
Object^ GetInfo(KY_STREAM_BUFFER_INFO_CMD info);
/// <summary>
/// Retrieves the size of the current buffer (frame)
/// </summary>
/// <returns>The size of the current buffer</returns>
System::UInt64^ getSize();
/// <summary>
/// Moves a previously announced buffer to specified queue.
/// </summary>
/// <param name='dstQueue'>Destination queue: KY_ACQ_QUEUE_INPUT, KY_ACQ_QUEUE_OUTPUT, KY_ACQ_QUEUE_UNQUEUED, KY_ACQ_QUEUE_AUTO</param>
/// <returns>The required Info</returns>
void BufferToQueue(KY_ACQ_QUEUE_TYPE dstQueue);
};
public ref class Lib
{
public:
Lib();
/// <summary>
/// An optional call before KYFGScan() and reserved for future usage
/// </summary>
/// <returns></returns>
void Initialize(InitParameters^ initParameters);
/// <summary>
/// Scans for KAYA devices currently connected to the PC PCIe slots and available virtual devices
/// </summary>
/// <returns>Number of connected devices</returns>
int Scan();
/// <summary>
/// Retrieve device name for the specified index. (DEPRECATED)
/// </summary>
/// <param name='dev_id'>discovered device index</param>
/// <returns>Device's name</returns>
//System::String^ DeviceDisplayName(int dev_index);
/// <summary>
/// Retrieve info about the device
/// </summary>
/// <param name='dev_index'>discovered device index</param>
/// <returns>Device's info</returns>
DEVICE_INFO^ DeviceInfo(int dev_index);
/// <summary>
/// Retrieve the software version
/// </summary>
/// <returns>Software version</returns>
SOFTWARE_VERSION^ GetSoftwareVersion();
/// <summary>
/// Connect to a specific Frame Grabber and initializes all required components.
/// </summary>
/// <param name='index'>The index, from scan result array acquired with KYFG_Scan() function, of the Frame Grabber device to open.</param>
/// <returns>Instance of Grabber class, that implements IDevice interface</returns>
IDevice^ Open(int index);
/// <summary>
/// Connect to a specific Frame Grabber and initializes all required components. Project file may be passed here in order to initialize Frame Grabber and Camera parameters with previously saved values.
/// </summary>
/// <param name='index'>The index, from scan result array acquired with Lib.Scan() function, of the Frame Grabber device to open.</param>
/// <param name='projectFile'>(optional) Full path of a project file with saved values. Input value can be NULL.</param>
/// <returns>Instance of Grabber class, that implements IDevice interface</returns>
IDevice^ OpenEx(int index, const System::String^ projectFile);
/// <summary>
/// Connect to a specific Frame Grabber and initializes all required components. Project file may be passed here in order to initialize Frame Grabber and Camera parameters with previously saved values.
/// </summary>
/// <param name='index'>The index, from scan result array acquired with Lib.Scan() function, of the Frame Grabber device to open.</param>
/// <returns>Instance of Grabber class, that implements IDevice interface</returns>
IDevice^ OpenEx(int index);
};
public ref class KYFGLibException : System::Exception
{
public:
KYFGLibException() : System::Exception() {}
KYFGLibException(System::String^ exp_str) : System::Exception(exp_str) {}
KYFGLibException(System::String^ exp_str, System::Exception^ inner_exp) : System::Exception(exp_str, inner_exp) {}
KYFGLibException(FGSTATUS err) : System::Exception("KYFGLibException has occured. Error code: 0x" + ((int)err).ToString("X")) {}
};
public ref class AuxData
{
public:
ref class IOData
{
public:
System::UInt64 masked_data;
System::UInt64 timestamp;
};
System::UInt32 messageID;
System::Boolean reserved;
System::Int64 dataSize;
IOData^ io_data;
AuxData(System::UInt32 message_id_arg, System::Boolean reserved_arg, System::Int64 data_size_arg, System::UInt64 masked_data_arg, System::UInt64 time_stamp_arg)
: messageID(message_id_arg), reserved(reserved_arg), dataSize(data_size_arg) {
io_data->masked_data = masked_data_arg;
io_data->timestamp = time_stamp_arg;
}
};
public ref class DEVICE_EVENT
{
public:
KYDEVICE_EVENT_ID DeviceEventId;
DEVICE_EVENT(KYDEVICE_EVENT_ID eventId) :
DeviceEventId(eventId)
{}
DEVICE_EVENT(KYDEVICE_EVENT* nativeDeviceEvent)
{
if (nativeDeviceEvent->eventId == ::KYDEVICE_EVENT_CAMERA_START_REQUEST)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CAMERA_START_REQUEST;
}
else if (nativeDeviceEvent->eventId == ::KYDEVICE_EVENT_CAMERA_CONNECTION_LOST_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CAMERA_CONNECTION_LOST_ID;
}
else if (nativeDeviceEvent->eventId == ::KYDEVICE_EVENT_SYSTEM_TEMPERATURE_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_SYSTEM_TEMPERATURE_ID;
}
else if (nativeDeviceEvent->eventId == ::KYDEVICE_EVENT_CXP2_HEARTBEAT_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CXP2_HEARTBEAT_ID;
}
else if (nativeDeviceEvent->eventId == ::KYDEVICE_EVENT_CXP2_EVENT_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CXP2_EVENT_ID;
}
else if (nativeDeviceEvent->eventId == ::KYDEVICE_EVENT_GENCP_EVENT_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_GENCP_EVENT_ID;
}
else if (nativeDeviceEvent->eventId == ::KYDEVICE_EVENT_GIGE_EVENTDATA_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_GIGE_EVENTDATA_ID;
}
}
DEVICE_EVENT(KYDEVICE_EVENT nativeDeviceEvent)
{
if (nativeDeviceEvent.eventId == ::KYDEVICE_EVENT_CAMERA_START_REQUEST)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CAMERA_START_REQUEST;
}
else if (nativeDeviceEvent.eventId == ::KYDEVICE_EVENT_CAMERA_CONNECTION_LOST_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CAMERA_CONNECTION_LOST_ID;
}
else if (nativeDeviceEvent.eventId == ::KYDEVICE_EVENT_SYSTEM_TEMPERATURE_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_SYSTEM_TEMPERATURE_ID;
}
else if (nativeDeviceEvent.eventId == ::KYDEVICE_EVENT_CXP2_HEARTBEAT_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CXP2_HEARTBEAT_ID;
}
else if (nativeDeviceEvent.eventId == ::KYDEVICE_EVENT_CXP2_EVENT_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_CXP2_EVENT_ID;
}
else if (nativeDeviceEvent.eventId == ::KYDEVICE_EVENT_GENCP_EVENT_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_GENCP_EVENT_ID;
}
else if (nativeDeviceEvent.eventId == ::KYDEVICE_EVENT_GIGE_EVENTDATA_ID)
{
DeviceEventId = KYDEVICE_EVENT_ID::DEVICE_EVENT_GIGE_EVENTDATA_ID;
}
}
};
public ref class DEVICE_EVENT_CAMERA_START
{
public:
DEVICE_EVENT^ DeviceEvent;
Camera^ CamObj;
DEVICE_EVENT_CAMERA_START(KYDEVICE_EVENT_CAMERA_START* unmanagedDeviceEventCameraStart);
};
public ref class DEVICE_EVENT_CAMERA_CONNECTION_LOST
{
public:
DEVICE_EVENT^ DeviceEvent;
Camera^ CamObj;
System::UInt64^ DeviceLink;
System::UInt64^ CameraLink;
DEVICE_EVENT_CAMERA_CONNECTION_LOST(KYDEVICE_EVENT_CAMERA_CONNECTION_LOST* unmanagedDeviceEvent);
};
public ref class DEVICE_EVENT_SYSTEM_TEMPERATURE
{
public:
DEVICE_EVENT^ DeviceEvent;
KYDEVICE_EVENT_SYSTEM_TEMPERATURE_THRESHOLD_ID temperatureThresholdId;
DEVICE_EVENT_SYSTEM_TEMPERATURE(KYDEVICE_EVENT_SYSTEM_TEMPERATURE* unmanagedDeviceEvent);
};
public ref class CXP2_HEARTBEAT
{
public:
System::UInt32 masterHostConnectionID; //according to CXP 2.0 standard, holds the Host Connection ID of the Host connection
//connected to the Device Master connection
System::UInt64 cameraTime; // The Device time is expressed in nanoseconds.
// Note that this field is called "Device time" in the CXP standard
// but in this API the notion "device" is used for PCI devices - grabbers and simulators
CXP2_HEARTBEAT(System::UInt32 connectionID, System::UInt64 cameraTime) :
masterHostConnectionID(connectionID), cameraTime(cameraTime) {}
};
public ref class DEVICE_EVENT_CXP2_HEARTBEAT
{
public:
DEVICE_EVENT^ DeviceEvent;
Camera^ CamObj;
CXP2_HEARTBEAT^ heartBeat;
DEVICE_EVENT_CXP2_HEARTBEAT(KYDEVICE_EVENT_CXP2_HEARTBEAT* unmanagedDeviceEvent);
};
public ref class CXP2_EVENT
{
public:
System::UInt32 masterHostConnectionID; //according to CXP 2.0 standard, holds the Host Connection ID of the Host connection
//connected to the Device Master connection
System::Byte tag; // 8 bit tag. Incremented for each new Event packet.
System::UInt16 dataSize; // the number of event data words, Maximum size = CXP_EVENT_MAX_DATA_SIZE bytes according to CXP 2.0 standard
array<System::UInt32>^ dataWords = gcnew array<System::UInt32>(KY_CXP_EVENT_MAX_DATA_SIZE / 4); // 'dataSize' words with one or more event messages
CXP2_EVENT(uint32_t connectionID, uint8_t tag, uint16_t size, uint32_t dwords[]) :
masterHostConnectionID(connectionID), tag(tag), dataSize(size)
{
for (int i = 0; i <= dataSize; i++)
{
dataWords[i] = System::Convert::ToUInt32(dwords[i]);
}
}
};
public ref class DEVICE_EVENT_CXP2_EVENT
{
public:
DEVICE_EVENT^ DeviceEvent;
Camera^ CamObj;
CXP2_EVENT^ cxp2Event;
DEVICE_EVENT_CXP2_EVENT(KYDEVICE_EVENT_CXP2_EVENT* unmanagedDeviceEvent);
};
public ref class DEVICE_EVENT_GENCP_EVENT
{
public:
ref class GENCP_EVENT
{
public:
System::UInt16^ eventSize; // Size of event data object in bytes including event_size, event_id, timestamp and optional data.
System::UInt16^ eventId; // The event_id is a number identifying an event source.
System::UInt64^ timestamp; // 64 bit timestamp value in ns as defined in the timestamp bootstrap register.
array<System::Byte>^ dataPayload = gcnew array<System::Byte>(KY_GENCP_EVENT_MAX_DATA_SIZE); // Create managed buffer
GENCP_EVENT(uint16_t eventSize, uint16_t eventId, uint64_t timestamp, uint8_t data[]) :
eventSize(eventSize), eventId(eventId), timestamp(timestamp)
{
for (int i = 0; i <= KY_GENCP_EVENT_MAX_DATA_SIZE; i++)
{
dataPayload[i] = System::Convert::ToByte(data[i]);
}
}
};
DEVICE_EVENT^ DeviceEvent;
System::Int32^ srcDevicePort;
GENCP_EVENT^ gencpEvent;
DEVICE_EVENT_GENCP_EVENT(KYDEVICE_EVENT_GENCP_EVENT* unmanagedDeviceEvent);
};
public ref class DEVICE_EVENT_GIGE_EVENTDATA
{
public:
ref class GIGE_EVENTDATA_EVENT
{
public:
System::UInt16^ eventSize; // Size of event data object in bytes including event_size, event_id, timestamp and optional data.
System::UInt16^ eventId; // The event_id is a number identifying an event source.
System::UInt16^ streamChannel;
System::UInt16^ blockId;
System::UInt64^ timestamp; // 64 bit timestamp value in ns as defined in the timestamp bootstrap register.
array<System::Byte>^ dataPayload = gcnew array<System::Byte>(KY_GIGE_EVENTDATA_EVENT_MAX_DATA_SIZE); // data payload
GIGE_EVENTDATA_EVENT(uint16_t eventSize, uint16_t eventId, uint16_t streamChannel, uint16_t blockId, uint64_t timestamp, uint8_t data[]) :
eventSize(eventSize), eventId(eventId), streamChannel(streamChannel), blockId(blockId), timestamp(timestamp)
{
for (int i = 0; i <= KY_GIGE_EVENTDATA_EVENT_MAX_DATA_SIZE; i++)
{
dataPayload[i] = System::Convert::ToByte(data[i]);
}
}
};
DEVICE_EVENT^ DeviceEvent;
System::Int32^ srcDevicePort;
GIGE_EVENTDATA_EVENT^ gigeEvent;
DEVICE_EVENT_GIGE_EVENTDATA(KYDEVICE_EVENT_GIGE_EVENTDATA* unmanagedDeviceEvent);
};
}

View File

@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug_vc141|Win32">
<Configuration>Debug_vc141</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug_vc141|x64">
<Configuration>Debug_vc141</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release_vc141|Win32">
<Configuration>Release_vc141</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release_vc141|x64">
<Configuration>Release_vc141</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B8EF8D5B-19F4-4EBE-B7D4-995BBCA680B8}</ProjectGuid>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>KYFGLibNET</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\KYGlobal\KYGlobal.props" Condition="exists('..\KYGlobal\KYGlobal.props')" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\KYGlobal\KYGlobal.props" Condition="exists('..\KYGlobal\KYGlobal.props')" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\KYGlobal\KYGlobal.props" Condition="exists('..\KYGlobal\KYGlobal.props')" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\KYGlobal\KYGlobal.props" Condition="exists('..\KYGlobal\KYGlobal.props')" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="exists('KYFGLibNET.snk')">
<LinkKeyFile>KYFGLibNET.snk</LinkKeyFile>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<AdditionalIncludeDirectories>$(KAYA_VISION_POINT_INCLUDE_PATH);$(ProjectDir)..\KYFGLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(KAYA_VISION_POINT_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>KYFGLib$(KYLIBNAME_SUFFIX_D)$(KYLIBNAME_SUFFIX).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command Condition="exists('..\KYGlobal\KYGlobal.props')" >xcopy "$(ProjectDir)\$(Configuration)$(PlatformArchitecture)\$(TargetName)$(TargetExt)" "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\" /Y /I /D</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<AdditionalIncludeDirectories>$(KAYA_VISION_POINT_INCLUDE_PATH);$(ProjectDir)..\KYFGLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(KAYA_VISION_POINT_LIB_PATH);</AdditionalLibraryDirectories>
<AdditionalDependencies>KYFGLib$(KYLIBNAME_SUFFIX_D)$(KYLIBNAME_SUFFIX).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command Condition="exists('..\KYGlobal\KYGlobal.props')" >xcopy "$(ProjectDir)\$(Configuration)$(PlatformArchitecture)\$(TargetName)$(TargetExt)" "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\" /Y /I /D
copy "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\KYFGLib.NET$(KYLIBNAME_SUFFIX_D)_vc141.dll" "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\KYFGLib.NET$(KYLIBNAME_SUFFIX_D).dll" /B /Y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<AdditionalIncludeDirectories>$(KAYA_VISION_POINT_INCLUDE_PATH);$(ProjectDir)..\KYFGLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(KAYA_VISION_POINT_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>KYFGLib$(KYLIBNAME_SUFFIX_D)$(KYLIBNAME_SUFFIX).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command Condition="exists('..\KYGlobal\KYGlobal.props')" >xcopy "$(ProjectDir)\$(Configuration)$(PlatformArchitecture)\$(TargetName)$(TargetExt)" "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\" /Y /I /D</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_vc141|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<AdditionalIncludeDirectories>$(KAYA_VISION_POINT_INCLUDE_PATH);$(ProjectDir)..\KYFGLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(KAYA_VISION_POINT_LIB_PATH)</AdditionalLibraryDirectories>
<AdditionalDependencies>KYFGLib$(KYLIBNAME_SUFFIX_D)$(KYLIBNAME_SUFFIX).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command Condition="exists('..\KYGlobal\KYGlobal.props')" >xcopy "$(ProjectDir)\$(Configuration)$(PlatformArchitecture)\$(TargetName)$(TargetExt)" "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\" /Y /I /D
copy "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\KYFGLib.NET$(KYLIBNAME_SUFFIX_D)_vc141.dll" "$(ProjectDir)..\..\TESTDIR\$(Platform)\Common\Bin\KYFGLib.NET$(KYLIBNAME_SUFFIX_D).dll" /B /Y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="KYFGLib.NET.h" />
<ClInclude Include="KYFGLib_Camera.h" />
<ClInclude Include="KYFGLib_Device.h" />
<ClInclude Include="KYFGLib_Stream.h" />
<ClInclude Include="KYFGLib_StreamBuffer.h" />
<ClInclude Include="KYFGLib_utils.h" />
<ClInclude Include="KY_Parameters.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="KYFGLib.NET.cpp" />
<ClCompile Include="KYFGLib_Camera.cpp" />
<ClCompile Include="KYFGLib_Device.cpp" />
<ClCompile Include="KYFGLib_Stream.cpp" />
<ClCompile Include="KYFGLib_StreamBuffer.cpp" />
<ClCompile Include="KYFGLib_utils.cpp" />
<ClCompile Include="KY_Parameters.cpp" />
<ClCompile Include="Stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_vc141|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release_vc141|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release_vc141|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="app.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="KYFGLib.NET.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KYFGLib_Camera.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KYFGLib_Stream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KYFGLib_StreamBuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KYFGLib_utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KYFGLib_Device.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KY_Parameters.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="KYFGLib.NET.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AssemblyInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KYFGLib_Camera.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KYFGLib_Stream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KYFGLib_StreamBuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KYFGLib_utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KYFGLib_Device.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KY_Parameters.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="app.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,25 @@
#pragma once
#include "KYFGLib.h"
#include "KYFGLib.NET.h"
namespace KAYA
{
public ref class Buffer : Ibuffer
{
private:
BUFFHANDLE handle;
public:
Buffer(BUFFHANDLE h): handle(h) {}
BUFFHANDLE get_handle() { return handle; }
};
}

View File

@@ -0,0 +1,697 @@
#include "Stdafx.h"
#include "KYFGLib.NET.h"
#include "KYFGLib_Camera.h"
#include "KYFGLib_Stream.h"
//using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
namespace KAYA
{
CAMERA_INFO^ Camera::CameraInfo()
{
return cam_info;
}
void Camera::Open(System::String^ xml_file_path)
{
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi(xml_file_path); // Create native char* pointer to string with param name
const char* native_xml_file_path = (const char*) (param_name_ptr.ToPointer());
FGSTATUS KYFG_CameraOpen2_status = ::KYFG_CameraOpen2(m_camhandle, native_xml_file_path); // Calling the func
if (KYFG_CameraOpen2_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_CameraOpen2_status);
}
return;
}
void Camera::SetValueEnum_ByValueName(const System::String^ paramName, const System::String^ param)
{
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Create native char* pointer to string with param name
const char* param_name_str = (const char*) (param_name_ptr.ToPointer());
IntPtr param_value_ptr = Marshal::StringToHGlobalAnsi((System::String^)param); // Create native char* pointer to string with param value
const char* param_value_str = (const char*) (param_value_ptr.ToPointer());
FGSTATUS KYFG_SetValueEnum_ByValueName_status = ::KYFG_SetCameraValueEnum_ByValueName(m_camhandle, param_name_str, param_value_str); // Calling the func
if (KYFG_SetValueEnum_ByValueName_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_SetValueEnum_ByValueName_status);
}
Marshal::FreeHGlobal(param_name_ptr); // Release param_name_ptr
Marshal::FreeHGlobal(param_value_ptr); // Release param_value_ptr
return;
}
/*
* @brief: A new stream will be allocated for specified camera. The created stream buffers will hold the data of acquired frames.
* Stream buffer acquisition mechanism and buffer size calculations are handled internally.
* Buffer frame size is calculated with consideration of specified number of frames, in addition to camera and grabber
* configuration parameters set previously to this function call. Changing certain camera/grabber parameters, after
* successfully stream allocation, might result in unstable software operation, memory leaks and even total system crash.
* @params:
* frames - Number of frames that should be allocated for this stream.
* @return: IStream handle of newly created stream
*/
IStream^ Camera::StreamCreateAndAlloc(int frames)
{
STREAM_HANDLE streamHandle = 0;
int stream_index = 0;
FGSTATUS KYFG_StreamCreateAndAlloc_status = ::KYFG_StreamCreateAndAlloc(m_camhandle, &streamHandle, frames, stream_index); // Calling func
if (KYFG_StreamCreateAndAlloc_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_StreamCreateAndAlloc_status);
}
Stream^ new_stream = gcnew Stream(streamHandle); // Create & return new Sream handle
return new_stream;
}
/*
* @brief: A new stream will be created for the chosen camera. The stream will manage frame buffers allocated either
* by user or by library. Frame buffers will be organized in queues <20> input, output,
* automatic <20> and in a set of unqueued frame buffers.
* @params:
* @return: IStream handle of newly created stream
*/
IStream^ Camera::StreamCreate()
{
STREAM_HANDLE streamHandle = 0;
int stream_index = 0;
FGSTATUS KYFG_StreamCreate_status = ::KYFG_StreamCreate(m_camhandle, &streamHandle, stream_index); // Calling func
if (KYFG_StreamCreate_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_StreamCreate_status);
}
Stream^ new_stream = gcnew Stream(streamHandle); // Create & return new Stream handle
return new_stream;
}
void Camera::Start(IStream^ streamHandle, int frames)
{
STREAM_HANDLE current_streamHandle = ((Stream^)streamHandle)->get_handle(); // Getting original STREAM_HANDLE native handle
FGSTATUS KYFG_CameraStart_status = ::KYFG_CameraStart(m_camhandle, current_streamHandle, frames); // Calling function
if (KYFG_CameraStart_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_CameraStart_status);
}
return;
}
void Camera::Stop()
{
FGSTATUS KYFG_CameraStop_status = ::KYFG_CameraStop(m_camhandle); // Calling function
if (KYFG_CameraStop_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_CameraStop_status);
}
return;
}
/*
* @brief: Extracts native XML file from chosen camera and fills user allocated buffer. The size (in bytes) and file type (.xml or .zip) are also retrieved even if buffer isn<73>t large enough to hold all file data.
* @params:
* stream_index - Index of stream. Currently unused and must be 0.
* @return: Byte array, which contains the required XML
*/
System::Tuple<array<System::Byte>^, KYBOOL>^ Camera::GetXML()
{
::KYBOOL isZip;
uint64_t buf_size = 0;
KYBOOL isZip_managed;
FGSTATUS KYFG_CameraGetXML_status = ::KYFG_CameraGetXML(m_camhandle,nullptr, &isZip, &buf_size); // Calling first time to retrieve ZIP status and buffer size
isZip_managed = isZip == KYTRUE ? KYBOOL::KY_TRUE : KYBOOL::KY_FALSE;
//Console::WriteLine("isZip: {0}, size: {1}", (int)isZip, (int)buf_size);
char* xml_native_string = KY_NEW_ARRAY char[size_t(buf_size)]; // Getting native pointer to xml string
KYFG_CameraGetXML_status = ::KYFG_CameraGetXML(m_camhandle, xml_native_string, &isZip, &buf_size); // Calling func second time with proper parameters
if (KYFG_CameraGetXML_status != FGSTATUS_OK) // Error checking
{
throw gcnew KYFGLibException(KYFG_CameraGetXML_status);
}
array<System::Byte>^ xml_managed_string = gcnew array<System::Byte>((int)buf_size); // Creating managed array for xml string
System::Runtime::InteropServices::Marshal::Copy( IntPtr( ( char* ) xml_native_string ), xml_managed_string, 0, (int)buf_size ); // Copying data to managed string
System::Tuple<array<System::Byte>^, KYBOOL>^ return_tuple = gcnew System::Tuple<array<System::Byte>^, KYBOOL>(xml_managed_string, isZip_managed);
return return_tuple;
}
void Camera::Close()
{
FGSTATUS KYFG_CameraClose_status = ::KYFG_CameraClose(m_camhandle); // Calling the function
if (KYFG_CameraClose_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_CameraClose_status);
}
return;
}
/*
* @brief: Direct write data buffer to the selected camera.
* @params:
* address - Start address of the data to write
* buffer - buffer data to write
* @return: size of written bytes
*/
System::UInt32 Camera::WriteReg(System::UInt64 address, array<System::Byte>^ buffer)
{
uint64_t add = address;
cli::pin_ptr<System::Byte> p = &buffer[0]; // Getting native pointer to buffer
unsigned char* native_buffer = p;
uint32_t buf_size = buffer->Length; // Retrieving buffer Length
FGSTATUS KYFG_CameraWriteReg_status = ::KYFG_CameraWriteReg(m_camhandle, address, native_buffer, &buf_size); // Calling native function
if (KYFG_CameraWriteReg_status != FGSTATUS_OK) //Error check
{
throw gcnew KYFGLibException(KYFG_CameraWriteReg_status);
}
return buf_size;
}
/*
* @brief: Direct read data buffer from the selected camera.
* @params:
* address - Start address of the data to read
* size - Buffer data to write
* @return: Buffer that will hold read data
*/
array<System::Byte>^ Camera::ReadReg(System::UInt64 address, System::UInt32 size)
{
uint64_t add = address;
uint32_t buf_size = size;
array<System::Byte>^ managed_buffer = gcnew array<System::Byte>(size); // Create managed buffer
cli::pin_ptr<System::Byte> p = &managed_buffer[0]; // Getting native pointer to buffer
unsigned char* native_buffer = p;
// Calling native function, Filling buffer(s) with a relevant data
FGSTATUS KYFG_CameraReadReg_status = ::KYFG_CameraReadReg(m_camhandle, address, native_buffer, &buf_size); // Calling func
if (KYFG_CameraReadReg_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_CameraReadReg_status);
}
return managed_buffer;
}
// TODO: Recheck next func
/*
* @brief: Set Camera configuration field value.
* @params:
* paramName - Name of configuration parameter
* paramValue - Object, that represents a param value corresponding to the param name.
* Can be Int32, Boolean, String, Float, Int64(enum)
* @return: 0
* @note:
* The runtime type of Object could be retrieved in run time
*/
void Camera::SetValue(const System::String^ paramName, Object^ paramValue)
{
FGSTATUS KYFG_SetCameraValue_status;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
System::Type^ param_type = paramValue->GetType();
KY_CAM_PROPERTY_TYPE internal_value_type = ::KYFG_GetCameraValueType(m_camhandle, native_param_name_str); // First check what the return type
if ( param_type->Equals(System::Int16::typeid) || param_type->Equals(System::Int32::typeid) || param_type->Equals(System::Int64::typeid) ||
param_type->Equals(System::UInt16::typeid) || param_type->Equals(System::UInt32::typeid) )
{
System::Int64 managed_param_value = Convert::ToInt64(paramValue);
int64_t native_param_value = (int64_t)managed_param_value;
KYFG_SetCameraValue_status = ::KYFG_SetCameraValue(m_camhandle, native_param_name_str, &native_param_value); // Calling func
}
else if( param_type->Equals(System::Boolean::typeid))
{
bool native_param_value = (System::Boolean)paramValue;
KYFG_SetCameraValue_status = ::KYFG_SetCameraValue(m_camhandle, native_param_name_str, &native_param_value); // Calling func
}
else if( param_type->Equals(System::String::typeid))
{
IntPtr param_value_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramValue); // Getting native char* pointer to string with param Name
const char* native_param_value = (const char*) (param_value_ptr.ToPointer());
if ( internal_value_type == PROPERTY_TYPE_ENUM)
{
KYFG_SetCameraValue_status = ::KYFG_SetCameraValueEnum_ByValueName(m_camhandle, native_param_name_str, native_param_value);
} else
{
KYFG_SetCameraValue_status = ::KYFG_SetCameraValue(m_camhandle, native_param_name_str, &native_param_value); // Calling func
}
}
else if( param_type->Equals(System::Single::typeid))
{
double native_param_value = (System::Single)paramValue;
KYFG_SetCameraValue_status = ::KYFG_SetCameraValue(m_camhandle, native_param_name_str, &native_param_value); // Calling func
}
else if(param_type->Equals(System::Double::typeid))
{
double native_param_value = (System::Double)paramValue;
KYFG_SetCameraValue_status = ::KYFG_SetCameraValue(m_camhandle, native_param_name_str, &native_param_value); // Calling func
}
else if(param_type->Equals(System::Byte::typeid))
{
unsigned char native_param_value = (System::Byte)paramValue;
KYFG_SetCameraValue_status = ::KYFG_SetCameraValue(m_camhandle, native_param_name_str, &native_param_value); // Calling func
}
else if(param_type->Equals(cli::array<Byte>::typeid))
{
array<Byte>^ paramValue_array = (array<Byte>^)(paramValue);
cli::pin_ptr<System::Byte> p = &paramValue_array[0]; // Getting native pointer to buffer
unsigned char* native_buffer = p;
uint32_t buf_size = paramValue_array->Length;
KYFG_SetCameraValue_status = ::KYFG_SetCameraValue(m_camhandle, native_param_name_str, &native_buffer);
}
else
{
throw gcnew KYFGLibException("KYFGLib Error: PROPERTY_TYPE_UNSUPPORTED");
}
if (KYFG_SetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_SetCameraValue_status);
}
return;
}
/*
* @brief: Get Camera configuration field value.
* @params:
* paramName - Name of configuration parameter
* @return:
* paramValue - Object, that represents a param value corresponding to the param name.
* Can be Int32, Boolean, String, Float, Int64(enum) or String(representing command name)
* @note:
* The runtime type of Object could be retrieved in run time
*/
Object^ Camera::GetValue(const System::String^ paramName)
{
uint8_t* native_param_value_reg;
uint32_t reg_size = 0;
Object^ paramValue;
FGSTATUS KYFG_GetCameraValue_status;
System::String^ managed_param_str_enum;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
KY_CAM_PROPERTY_TYPE value_type = ::KYFG_GetCameraValueType(m_camhandle, native_param_name_str); // First check what the return type
switch(value_type)
{
case PROPERTY_TYPE_INT:
int64_t native_param_value_int;
KYFG_GetCameraValue_status = ::KYFG_GetCameraValue(m_camhandle, native_param_name_str, &native_param_value_int);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
paramValue = gcnew System::Int64(native_param_value_int); // Create new Int64
break;
case PROPERTY_TYPE_BOOL:
bool native_param_value_bool;
KYFG_GetCameraValue_status = ::KYFG_GetCameraValue(m_camhandle, native_param_name_str, &native_param_value_bool);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
paramValue = gcnew System::Boolean(native_param_value_bool); // Create new Boolean
break;
case PROPERTY_TYPE_STRING:
{
char* native_param_value_str = nullptr;
unsigned int native_param_value_str_size = 0;
::KYFG_GetCameraValueStringCopy(m_camhandle, native_param_name_str, native_param_value_str, &native_param_value_str_size);
native_param_value_str = KY_NEW_ARRAY char[native_param_value_str_size + 1];
KYFG_GetCameraValue_status = ::KYFG_GetCameraValueStringCopy(m_camhandle, native_param_name_str, native_param_value_str, &native_param_value_str_size);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
// TODO: Sometimes there is an error: Pointer mustn't be in lower 64k address space
paramValue = gcnew System::String(native_param_value_str); // Create new String
delete native_param_value_str;
break;
}
case PROPERTY_TYPE_FLOAT:
double native_param_value_float;
KYFG_GetCameraValue_status = ::KYFG_GetCameraValue(m_camhandle, native_param_name_str, &native_param_value_float);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
paramValue = gcnew System::Double(native_param_value_float); // Create new Float
break;
case PROPERTY_TYPE_ENUM:
{
static bool bNewNetEnum = true;
if (bNewNetEnum)
{
Type^ theType = m_KY_Parameters->GetEnumParameterType(native_param_name_str);
int64_t native_param_value_int;
KYFG_GetCameraValue_status = ::KYFG_GetCameraValue(m_camhandle, native_param_name_str, &native_param_value_int);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
paramValue = Enum::ToObject(theType, native_param_value_int);
}// bNewNetEnum
else
{
int64_t native_param_value_enum;
KYFG_GetCameraValue_status = ::KYFG_GetCameraValue(m_camhandle, native_param_name_str, &native_param_value_enum);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
managed_param_str_enum = this->GetValueString(paramName);
paramValue = gcnew System::Tuple<System::String^, System::Int64>(managed_param_str_enum, System::Int64(native_param_value_enum));
}
}
break;
case PROPERTY_TYPE_COMMAND: // Returns KY_TRUE - if the command has been executed, KY_FALSE -otherwise.
::KYBOOL native_param_value_command;
KYFG_GetCameraValue_status = ::KYFG_GetCameraValue(m_camhandle, native_param_name_str, &native_param_value_command);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
paramValue = gcnew KYBOOL(native_param_value_command == 1 ? KYBOOL::KY_TRUE : KYBOOL::KY_FALSE);
break;
case PROPERTY_TYPE_REGISTER:
KYFG_GetCameraValue_status = ::KYFG_GetCameraValueRegister(m_camhandle, native_param_name_str, nullptr, &reg_size);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
native_param_value_reg = KY_NEW_ARRAY uint8_t[reg_size];
KYFG_GetCameraValue_status = ::KYFG_GetCameraValue(m_camhandle, native_param_name_str, native_param_value_reg);
if (KYFG_GetCameraValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValue_status);
}
paramValue = gcnew array<System::Byte>((int)reg_size); // Creating managed array for register data
System::Runtime::InteropServices::Marshal::Copy(IntPtr(( uint8_t*) native_param_value_reg), (array<System::Byte>^)paramValue, 0, (int)reg_size ); // Copying data to managed buffer
break;
default:
throw gcnew KYFGLibException("KYFGLib Error: PROPERTY_TYPE_UNKNOWN");
break;
}
return paramValue;
}
/*
* @brief: Get Camera integer value min, max configuration.
* @params:
* paramName - Name of configuration parameter
* @return:
* paramMinMaxValue - Tuple, that represents min, max param values corresponding to the param name.
*/
Object^ Camera::GetValueIntMaxMin(const System::String^ paramName)
{
int64_t native_param_value_int_min, native_param_value_int_max;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*)(param_name_ptr.ToPointer());
FGSTATUS KYFG_GetCameraValueIntMaxMin_status = ::KYFG_GetCameraValueIntMaxMin(m_camhandle, native_param_name_str, &native_param_value_int_max, &native_param_value_int_min);
System::Tuple<System::Int64, System::Int64>^ paramMinMaxValue = gcnew System::Tuple<System::Int64, System::Int64>(System::Int64(native_param_value_int_max), System::Int64(native_param_value_int_min));
// returning Tuple
return paramMinMaxValue;
}
/*
* @brief: Get Camera float value min, max configuration.
* @params:
* paramName - Name of configuration parameter
* @return:
* paramMinMaxValue - Tuple, that represents min, max param values corresponding to the param name.
*/
Object^ Camera::GetValueFloatMaxMin(const System::String^ paramName)
{
double native_param_value_int_min, native_param_value_int_max;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*)(param_name_ptr.ToPointer());
FGSTATUS KYFG_GetCameraValueFloatMaxMin_status = ::KYFG_GetCameraValueFloatMaxMin(m_camhandle, native_param_name_str, &native_param_value_int_max, &native_param_value_int_min);
System::Tuple<System::Double, System::Double>^ paramMinMaxValue = gcnew System::Tuple<System::Double, System::Double>(System::Double(native_param_value_int_max), System::Double(native_param_value_int_min));
// returning Tuple
return paramMinMaxValue;
}
/*
* @brief:
* Execute camera/Frame Grabber command; applicable for values of Command type.
* According to Gen<i>Cam standard naming and xml field definition and type.
* @params:
* paramName - Name of configuration parameter
*/
void Camera::ExecuteCommand(const System::String^ paramName)
{
FGSTATUS KYFG_CameraExecuteCommand_status;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
KYFG_CameraExecuteCommand_status = ::KYFG_CameraExecuteCommand(m_camhandle, native_param_name_str);
if (KYFG_CameraExecuteCommand_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_CameraExecuteCommand_status);
}
return;
}
/*
* @brief:
* Get camera configuration value of String type field.
* @params:
* paramName - Name of configuration parameter
* @return:
* paramValue - String value for chosen parameter
*/
System::String^ Camera::GetValueString(const System::String^ paramName)
{
FGSTATUS KYFG_GetCameraValueString_status;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
char* native_param_value_str;
// The function KYFG_GetCameraValueString() was deprecated, therefore we change it to KYFG_GetCameraValueStringCopy()
// KYFG_GetCameraValueString_status = ::KYFG_GetCameraValueString(handle, native_param_name_str, &native_param_value_str);
// The following block will replace the deprecated KYFG_GetCameraValueString() call
uint32_t stringSize = 0;
KYFG_GetCameraValueString_status = ::KYFG_GetCameraValueStringCopy(m_camhandle, native_param_name_str, nullptr, &stringSize); // Get requires string size
if (KYFG_GetCameraValueString_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValueString_status);
}
native_param_value_str = KY_NEW_ARRAY char[stringSize]; // allocate the string
KYFG_GetCameraValueString_status = ::KYFG_GetCameraValueStringCopy(m_camhandle, native_param_name_str, native_param_value_str, &stringSize); // Receive unmanaged string
if (KYFG_GetCameraValueString_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetCameraValueString_status);
}
// End Of replacing block
String^ paramValue = gcnew System::String(native_param_value_str); // Create new managed String from the received unmanaged char* string
delete(native_param_value_str);
return paramValue;
}
/*************************************************************************************
******************************** Camera CallBack ********************************
*************************************************************************************/
void Camera::CameraCallback_func(void* context, STREAM_HANDLE stream_handle)
{
Stream^ sHandle = gcnew Stream(stream_handle);
if (context == nullptr)
{
CameraCallback_delegator->Invoke(nullptr, sHandle);
} else {
IntPtr managed_userContext(context);
GCHandle handle = GCHandle::FromIntPtr(managed_userContext);
Object^ obj = (Object^)handle.Target;
CameraCallback_delegator->Invoke(obj, sHandle);
}
}
/*
* @brief: Register a camera runtime acquisition callback function.
* @params:
* delegator - Delegator to callback function
* userContext - User defined context to identify the received callback
*/
void Camera::CameraCallbackRegister(CameraCallback^ delegator, Object^ userContext)
{
FGSTATUS KYFG_CameraCallbackRegister_status;
// Save the received delegator
CameraCallback_delegator = delegator;
// Get native function pointer to Internal Callback function
Internal_CameraCallback_delegator = gcnew InternalCameraCallback(this, &KAYA::Camera::CameraCallback_func);
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_CameraCallback_delegator);
::CameraCallback cb_func = static_cast<::CameraCallback>(ip.ToPointer());
// Check if userContext presents and envoke KYFG_StreamBufferCallbackRegister()
// If userContext presents -> convert it to Object
if (userContext == nullptr)
{
KYFG_CameraCallbackRegister_status = ::KYFG_CameraCallbackRegister(m_camhandle, cb_func, 0);
} else {
GCHandle gc_handle = GCHandle::Alloc(userContext);
IntPtr pointer = GCHandle::ToIntPtr(gc_handle);
void* ptr = pointer.ToPointer();
KYFG_CameraCallbackRegister_status = ::KYFG_CameraCallbackRegister(m_camhandle, cb_func, ptr);
}
if (KYFG_CameraCallbackRegister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_CameraCallbackRegister_status);
}
return;
}
/*
* @brief: Register a camera runtime acquisition callback function.
* @params:
* delegator - Delegator to callback function
* userContext - User defined context to identify the received callback
*/
void Camera::CameraCallbackRegister(CameraCallback^ delegator)
{
return Camera::CameraCallbackRegister(delegator, nullptr);
}
/*
* @brief: Unregister a camera runtime acquisition callback function.
* @params:
* delegator - Delegator to callback function
*/
void Camera::CameraCallbackUnregister(CameraCallback^ delegator)
{
// Get Pointer to callback func
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_CameraCallback_delegator);
::CameraCallback cb_func = static_cast<::CameraCallback>(ip.ToPointer());
// Call the unregister func
FGSTATUS KYFG_CameraCallbackUnregister_status = ::KYFG_CameraCallbackUnregister(m_camhandle, cb_func);
if (KYFG_CameraCallbackUnregister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_CameraCallbackUnregister_status);
}
return;
}
void Camera::StreamLinkFramesContinuously(IStream^ streamHandle)
{
STREAM_HANDLE current_streamHandle = ((Stream^)streamHandle)->get_handle();
FGSTATUS KYFG_StreamLinkFramesContinuously_status = ::KYFG_StreamLinkFramesContinuously(current_streamHandle);
if (KYFG_StreamLinkFramesContinuously_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_StreamLinkFramesContinuously_status);
}
return;
}
/**
* @brief Send Event Message as specified by GenCP for CLHS, or EVENTDATA message for 10GigE
* @params:
* eventId - id of the event message
* buffer - buffer data to write
*/
void Camera::CameraSendEventMessage(System::UInt32 eventId, array<System::Byte>^ buffer)
{
uint32_t native_eventId = eventId;
cli::pin_ptr<System::Byte> p = &buffer[0];
unsigned char* native_buffer = p;
uint32_t buf_size = buffer->Length;
FGSTATUS KYFG_CameraSendEventMessage_status = ::KYFG_CameraSendEventMessage(m_camhandle, native_eventId, native_buffer, buf_size);
if (KYFG_CameraSendEventMessage_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_CameraSendEventMessage_status);
}
return;
}
}

View File

@@ -0,0 +1,81 @@
#pragma once
#include "KYFGLib.h"
#include "KYFGLib.NET.h"
#include "KY_Parameters.h"
namespace KAYA
{
public ref class Camera : public ICamera
{
private:
CAMHANDLE m_camhandle;
void CameraCallback_func(void* context, STREAM_HANDLE stream_handle);
CameraCallback^ CameraCallback_delegator;
InternalCameraCallback^ Internal_CameraCallback_delegator;
CAMERA_INFO^ cam_info;
KY_Parameters^ m_KY_Parameters;
public:
Camera(CAMHANDLE h)
: m_camhandle(h)
, m_KY_Parameters(gcnew KY_Parameters(m_camhandle))
{
}
Camera(CAMHANDLE h, unsigned char master_link_nat, unsigned char link_mask_nat, ::CXP_LINK_SPEED link_speed_nat, uint32_t stream_id_nat, char* deviceVersion_nat, char* deviceVendorName_nat,
char* deviceManufacturerInfo_nat, char* deviceModelName_nat, char* deviceID_nat, char* deviceUserID_nat, ::KYBOOL outputCamera_nat, ::KYBOOL virtualCamera_nat, char* deviceFirmwareVersion_nat)
: m_camhandle(h)
, m_KY_Parameters(gcnew KY_Parameters(m_camhandle))
{
cam_info = gcnew CAMERA_INFO( master_link_nat,
link_mask_nat,
link_speed_nat,
stream_id_nat,
deviceVersion_nat,
deviceVendorName_nat,
deviceManufacturerInfo_nat,
deviceModelName_nat,
deviceID_nat,
deviceUserID_nat,
outputCamera_nat,
virtualCamera_nat,
deviceFirmwareVersion_nat );
}
virtual CAMERA_INFO^ CameraInfo();
virtual void Open(System::String^ xml_file_path);
virtual void Close();
virtual void Start(IStream^ streamHandle, int frames);
virtual void Stop();
virtual void SetValueEnum_ByValueName(const System::String^ paramName, const System::String^ param);
virtual void SetValue(const System::String^ paramName, Object^ paramValue);
virtual Object^ GetValue(const System::String^ paramName);
virtual System::String^ GetValueString(const System::String^ paramName);
virtual void ExecuteCommand(const System::String^ paramName);
virtual Object^ GetValueIntMaxMin(const System::String^ paramName);
virtual Object^ GetValueFloatMaxMin(const System::String^ paramName);
virtual IStream^ StreamCreateAndAlloc(int frames);
virtual IStream^ StreamCreate();
virtual void StreamLinkFramesContinuously(IStream^ streamHandle);
virtual System::Tuple<array<System::Byte>^, KYBOOL>^ GetXML();
virtual System::UInt32 WriteReg(System::UInt64 address, array<System::Byte>^ buffer);
virtual array<System::Byte>^ ReadReg(System::UInt64 address, System::UInt32 size);
virtual void CameraCallbackRegister(CameraCallback^ delegator, Object^ userContext);
virtual void CameraCallbackRegister(CameraCallback^ delegator);
virtual void CameraCallbackUnregister(CameraCallback^ delegator);
virtual void CameraSendEventMessage(System::UInt32 eventId, array<System::Byte>^ buffer);
};
}

View File

@@ -0,0 +1,980 @@
#include "Stdafx.h"
#include "KYFGLib.NET.h"
#include "KYFGLib_Device.h"
#include "KYFGLib_Camera.h"
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
using namespace System::Diagnostics;
namespace KAYA
{
Device::Device(FGHANDLE h)
: m_fghandle(h)
, m_KY_Parameters(gcnew KY_Parameters(m_fghandle))
{
}
System::Collections::Generic::List<ICamera^>^ Device::CameraScan()
{
int detectedCamerasNum = 16;
CAMHANDLE CamHandleArray[16] = {0};
// Create List of cameras
System::Collections::Generic::List<ICamera^>^ camHandlesList = gcnew System::Collections::Generic::List<ICamera^>();
// Get all available cameras
FGSTATUS KYFG_CameraScan_status = ::KYFG_UpdateCameraList(m_fghandle, CamHandleArray, &detectedCamerasNum);
if (KYFG_CameraScan_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_CameraScan_status);
}
// Fill the cameras List
for(int i=0; i<detectedCamerasNum; i++)
{
/* Updating cam info */
::KYFGCAMERA_INFO2 cam_info_native;
cam_info_native.version = 1;
FGSTATUS KYFG_CameraInfo_status = ::KYFG_CameraInfo2(CamHandleArray[i], &cam_info_native);
Camera^ cam = gcnew Camera( CamHandleArray[i],
cam_info_native.master_link,
cam_info_native.link_mask,
cam_info_native.link_speed,
cam_info_native.stream_id,
cam_info_native.deviceVersion,
cam_info_native.deviceVendorName,
cam_info_native.deviceManufacturerInfo,
cam_info_native.deviceModelName,
cam_info_native.deviceID,
cam_info_native.deviceUserID,
cam_info_native.outputCamera,
cam_info_native.virtualCamera,
cam_info_native.deviceFirmwareVersion);
/* Example how to disable warnings
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4800)
#endif // #ifdef _MSC_VER
gcnew System::Boolean(cam_info_native.outputCamera),
gcnew System::Boolean(cam_info_native.virtualCamera));
#ifdef _MSC_VER
#pragma warning(pop)
#endif // #ifdef _MSC_VER
*/
/* End of Updating cam info */
camHandlesList->Add(cam);
}
return camHandlesList;
}
System::Collections::Generic::List<ICamera^>^ Device::UpdateCameraList()
{
CAMHANDLE CamHandleArray[16] = { 0 };
int detectedCamerasNum = 16;
// Create List of cameras
System::Collections::Generic::List<ICamera^>^ camHandlesList = gcnew System::Collections::Generic::List<ICamera^>();
// Get all available cameras
FGSTATUS KYFG_CameraScan_status = ::KYFG_UpdateCameraList(m_fghandle, CamHandleArray, &detectedCamerasNum);
if (KYFG_CameraScan_status != FGSTATUS_OK)
{
// Get stack trace information
StackTrace^ stackTrace = gcnew StackTrace(true);
array<StackFrame^>^ stackFrames = stackTrace->GetFrames();
String^ framesTraceString;
for (int i = 0; i < stackFrames->Length; i++)
{
framesTraceString += stackFrames[i]->ToString();
}
// Create the exception message
String^ exceptionMessage = String::Format("Device::UpdateCameraList() exception, FGSTATUS: 0x{0}, Frames size: {1}, Trace: {2}",
((int)KYFG_CameraScan_status).ToString("X"),
stackFrames->Length.ToString(),
framesTraceString);
// Throw the exception
throw gcnew KYFGLibException(exceptionMessage);
}
// Fill the cameras List
for (int i = 0; i<detectedCamerasNum; i++)
{
/* Updating cam info */
::KYFGCAMERA_INFO2 cam_info_native;
cam_info_native.version = 1;
FGSTATUS KYFG_CameraInfo_status = ::KYFG_CameraInfo2(CamHandleArray[i], &cam_info_native);
Camera^ cam = gcnew Camera( CamHandleArray[i],
cam_info_native.master_link,
cam_info_native.link_mask,
cam_info_native.link_speed,
cam_info_native.stream_id,
cam_info_native.deviceVersion,
cam_info_native.deviceVendorName,
cam_info_native.deviceManufacturerInfo,
cam_info_native.deviceModelName,
cam_info_native.deviceID,
cam_info_native.deviceUserID,
cam_info_native.outputCamera,
cam_info_native.virtualCamera,
cam_info_native.deviceFirmwareVersion);
camHandlesList->Add(cam);
}
return camHandlesList;
}
void Device::Close()
{
FGSTATUS KYFG_Close_status = ::KYFG_Close(m_fghandle);
if (KYFG_Close_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_Close_status);
}
return;
}
/*
* @brief: Write buffer of specified size to specific port.
* This function access the link directly disregarding the camera connection topology.
* @params:
* paramName - Name of configuration parameter
* paramValue - Object, that represents a param value corresponding to the param name.
* Can be Int32, Boolean, String, Float, Int64(enum)
* @note:
* The runtime type of Object could be retrieved in run time
*/
void Device::WritePortBlock(int port, System::UInt64 address, array<System::Byte>^ buffer)
{
uint64_t add = address;
cli::pin_ptr<System::Byte> p = &buffer[0]; // Getting native pointer to buffer
unsigned char* native_buffer = p;
uint32_t buf_size = buffer->Length; // Retrieving buffer Length
FGSTATUS KYFG_WritePortBlock_status = ::KYFG_WritePortBlock(m_fghandle, port, address, native_buffer, &buf_size); // Calling native function
if (KYFG_WritePortBlock_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_WritePortBlock_status);
}
return;
}
/*
* @brief: Write bootstrap registers from specific port, 32bit value each time.
* This function access the link directly disregarding the camera connection topology.
* @params:
* port - Frame Grabber port index
* address - Address of the register
* data - Bootstrap registers value
*/
void Device::WritePortReg(int port, System::UInt64 address, System::UInt32 data)
{
uint64_t add = address;
uint32_t native_data = data;
FGSTATUS KYFG_WritePortReg_status = ::KYFG_WritePortReg(m_fghandle, port, address, native_data); // Calling native function
if (KYFG_WritePortReg_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_WritePortReg_status);
}
return;
}
/*
* @brief: Read buffer of specified size from specific port.
* This function access the link directly disregarding the camera connection topology.
* @params:
* port - Frame Grabber port index
* address - Start address of the data to read
* size - Size in bytes of buffer to read
*/
array<System::Byte>^ Device::ReadPortBlock(int port, System::UInt64 address, System::UInt32 size)
{
uint64_t add = address;
uint32_t buf_size = size;
array<System::Byte>^ managed_buffer = gcnew array<System::Byte>(size); // Create managed buffer
cli::pin_ptr<System::Byte> p = &managed_buffer[0]; // Getting native pointer to buffer
unsigned char* native_buffer = p;
// Calling native function, Filling buffer(s) with a relevant data
FGSTATUS KYFG_ReadPortBlock_status = ::KYFG_ReadPortBlock(m_fghandle, port, address, native_buffer, &buf_size);
if (KYFG_ReadPortBlock_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_ReadPortBlock_status);
}
return managed_buffer;
}
System::UInt32 Device::ReadPortReg(int port, System::UInt64 address)
{
uint64_t add = address;
uint32_t native_data;
// Calling native function, Filling buffer(s) with a relevant data
FGSTATUS KYFG_ReadPortReg_status = ::KYFG_ReadPortReg(m_fghandle, port, address, &native_data);
if (KYFG_ReadPortReg_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_ReadPortReg_status);
}
System::UInt32 managed_data = native_data;
return managed_data;
}
System::Type^ Device::GetEnumParameterType(const char* native_param_name_str)
{
System::String ^ enumNameString = gcnew System::String(native_param_name_str);
EnumParametersMap::iterator it = m_EnumParameterMap.find(enumNameString);
if (it != m_EnumParameterMap.end())
{
return it->second;
}
// https://www.codeproject.com/Questions/1196327/Csharp-extend-an-enum-type-at-runtime
// https://docs.microsoft.com/en-us/archive/msdn-magazine/2010/july/cutting-edge-expando-objects-in-csharp-4
// https://stackoverflow.com/questions/25148388/dynamically-create-and-use-an-enumeration-type/25256727#25256727
FGSTATUS KYFG_GetGrabberValue_status;
EnumParameterDefinition enumParameterDefinition;
KYFG_GetGrabberValue_status = ::KY_GetEnumParameterDefinition(m_fghandle, native_param_name_str, enumParameterDefinition);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
// https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.enumbuilder?view=netframework-4.8
// + http://www.csharpbydesign.com/2009/01/automatically-generating-dynamic-enumerations.html
// Create Base Assembly Objects
#ifdef _DEBUG
System::String ^ assemblyNameString = "KYFGLibNetReflectionD";
#else
System::String ^ assemblyNameString = "KYFGLibNetReflection";
#endif
AppDomain^ appDomain = AppDomain::CurrentDomain;
AssemblyName^ asmName = gcnew AssemblyName(assemblyNameString);
AssemblyBuilder^ asmBuilder = appDomain->DefineDynamicAssembly(asmName, AssemblyBuilderAccess::Run);
// Create Module and Enumeration Builder Objects
ModuleBuilder^ modBuilder = asmBuilder->DefineDynamicModule(asmName + "_DynaModule");
EnumBuilder^ enumBuilder = modBuilder->DefineEnum(enumNameString, TypeAttributes::Public, int64_t::typeid);
for (const auto& enumEntry : enumParameterDefinition.m_Entries)
{
System::String ^ entryNameString = gcnew System::String(enumEntry.second.name.c_str());
enumBuilder->DefineLiteral(entryNameString, enumEntry.second.value);
}
Type^ theType = enumBuilder->CreateType();
m_EnumParameterMap[enumNameString] = theType;
return theType;
}
// TODO: Recheck next func
/*
* @brief: Set Frame Grabber configuration field value.
* @params:
* paramName - Name of configuration parameter
* paramValue - Object, that represents a param value corresponding to the param name.
* Can be Int32, Boolean, String, Float, Int64(enum)
* @note:
* The runtime type of Object could be retrieved in run time
*/
void Device::SetValue(const System::String^ paramName, Object^ paramValue)
{
FGSTATUS KYFG_SetGrabberValue_status;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
System::Type^ param_type = paramValue->GetType();
KY_CAM_PROPERTY_TYPE internal_value_type = ::KYFG_GetGrabberValueType(m_fghandle, native_param_name_str); // First check what the return type
if ( param_type->Equals(System::Int16::typeid) || param_type->Equals(System::Int32::typeid) || param_type->Equals(System::Int64::typeid) ||
param_type->Equals(System::UInt16::typeid) || param_type->Equals(System::UInt32::typeid) )
{
System::Int64 managed_param_value = Convert::ToInt64(paramValue);
int64_t native_param_value = (int64_t)managed_param_value;
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValue(m_fghandle, native_param_name_str, &native_param_value); // Calling func
}
else if( param_type->Equals(System::Boolean::typeid))
{
bool native_param_value = (System::Boolean)paramValue;
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValue(m_fghandle, native_param_name_str, &native_param_value); // Calling func
}
else if( param_type->Equals(System::String::typeid))
{
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramValue); // Getting native char* pointer to string with param Name
const char* native_param_value = (const char*) (param_name_ptr.ToPointer());
if ( internal_value_type == PROPERTY_TYPE_ENUM)
{
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValueEnum_ByValueName(m_fghandle, native_param_name_str, native_param_value);
}
else
{
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValue(m_fghandle, native_param_name_str, &native_param_value); // Calling func
}
}
else if( param_type->Equals(System::Single::typeid))
{
double native_param_value = (System::Single)paramValue;
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValue(m_fghandle, native_param_name_str, &native_param_value); // Calling func
}
else if( param_type->Equals(System::Double::typeid))
{
double native_param_value = (System::Double)paramValue;
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValue(m_fghandle, native_param_name_str, &native_param_value); // Calling func
}
else if( param_type->Equals(System::Byte::typeid))
{
unsigned char native_param_value = (System::Byte)paramValue;
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValue(m_fghandle, native_param_name_str, &native_param_value); // Calling func
}
else if(param_type->Equals(cli::array<Byte>::typeid))
{
array<Byte>^ paramValue_array = (array<Byte>^)(paramValue);
cli::pin_ptr<System::Byte> p = &paramValue_array[0]; // Getting native pointer to buffer
unsigned char* native_buffer = p;
uint32_t buf_size = paramValue_array->Length;
KYFG_SetGrabberValue_status = ::KYFG_SetGrabberValue(m_fghandle, native_param_name_str, &native_buffer);
}
else
{
throw gcnew KYFGLibException("KYFGLib Error: PROPERTY_TYPE_UNKNOWN");
}
if (KYFG_SetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_SetGrabberValue_status);
}
return;
}
/*
* @brief: Get Frame Grabber integer value min, max configuration.
* @params:
* paramName - Name of configuration parameter
* @return:
* paramMinMaxValue - Tuple, that represents min, max param values corresponding to the param name.
*/
Object^ Device::GetValueIntMaxMin(const System::String^ paramName)
{
int64_t native_param_value_int_min, native_param_value_int_max;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*)(param_name_ptr.ToPointer());
FGSTATUS KYFG_GetGrabberValueIntMaxMin_status = ::KYFG_GetGrabberValueIntMaxMin(m_fghandle, native_param_name_str, &native_param_value_int_max, &native_param_value_int_min);
System::Tuple<System::Int64, System::Int64>^ paramMinMaxValue = gcnew System::Tuple<System::Int64, System::Int64>(System::Int64(native_param_value_int_max), System::Int64(native_param_value_int_min));
// returning Tuple
return paramMinMaxValue;
}
/*
* @brief: Get Frame Grabber float value min, max configuration.
* @params:
* paramName - Name of configuration parameter
* @return:
* paramMinMaxValue - Tuple, that represents min, max param values corresponding to the param name.
*/
Object^ Device::GetValueFloatMaxMin(const System::String^ paramName)
{
double native_param_value_int_min, native_param_value_int_max;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*)(param_name_ptr.ToPointer());
FGSTATUS KYFG_GetGrabberValueFloatMaxMin_status = ::KYFG_GetGrabberValueFloatMaxMin(m_fghandle, native_param_name_str, &native_param_value_int_max, &native_param_value_int_min);
System::Tuple<System::Double, System::Double>^ paramMinMaxValue = gcnew System::Tuple<System::Double, System::Double>(System::Double(native_param_value_int_max), System::Double(native_param_value_int_min));
// returning Tuple
return paramMinMaxValue;
}
/*
* @brief: Get Frame Grabber configuration field value.
* @params:
* paramName - Name of configuration parameter
* @return:
* paramValue - Object, that represents a param value corresponding to the param name.
* Can be Int32, Boolean, String, Float, Int64(enum)
* @note:
* The runtime type of Object could be retrieved in run time
*/
Object^ Device::GetValue(const System::String^ paramName)
{
uint8_t* native_param_value_reg;
uint32_t reg_size = 0;
Object^ paramValue;
FGSTATUS KYFG_GetGrabberValue_status;
System::String^ managed_param_str_enum;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
KY_CAM_PROPERTY_TYPE value_type = ::KYFG_GetGrabberValueType(m_fghandle, native_param_name_str); // First check what the return type
switch(value_type)
{
case PROPERTY_TYPE_INT:
int64_t native_param_value_int;
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValue(m_fghandle, native_param_name_str, &native_param_value_int);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
paramValue = gcnew System::Int64(native_param_value_int); // Create new Int64
break;
case PROPERTY_TYPE_BOOL:
bool native_param_value_bool;
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValue(m_fghandle, native_param_name_str, &native_param_value_bool);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
paramValue = gcnew System::Boolean(native_param_value_bool); // Create new Boolean
break;
case PROPERTY_TYPE_STRING:
{
char* native_param_value_str = nullptr;
unsigned int native_param_value_str_size = 0;
::KYFG_GetGrabberValueStringCopy(m_fghandle, native_param_name_str, native_param_value_str, &native_param_value_str_size);
native_param_value_str = KY_NEW_ARRAY char[native_param_value_str_size + 1];
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValueStringCopy(m_fghandle, native_param_name_str, native_param_value_str, &native_param_value_str_size);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
paramValue = gcnew System::String(native_param_value_str); // Create new String
delete native_param_value_str;
break;
}
case PROPERTY_TYPE_FLOAT:
double native_param_value_float;
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValue(m_fghandle, native_param_name_str, &native_param_value_float);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
paramValue = gcnew System::Double(native_param_value_float); // Create new Float
break;
case PROPERTY_TYPE_ENUM:
{
static bool bNewNetEnum = true;
if (bNewNetEnum)
{
//Type^ theType = GetEnumParameterType(native_param_name_str);
Type^ theType = m_KY_Parameters->GetEnumParameterType(native_param_name_str);
int64_t native_param_value_int;
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValue(m_fghandle, native_param_name_str, &native_param_value_int);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
paramValue = Enum::ToObject(theType, native_param_value_int);
}// bNewNetEnum
else
{// returning Tuple
int64_t native_param_value_enum;
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValue(m_fghandle, native_param_name_str, &native_param_value_enum);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
managed_param_str_enum = this->GetValueString(paramName);
paramValue = gcnew System::Tuple<System::String^, System::Int64>(managed_param_str_enum, System::Int64(native_param_value_enum));
}// returning Tuple
}
break;
case PROPERTY_TYPE_COMMAND: // Returns KY_TRUE - if the command has been executed, KY_FALSE -otherwise.
::KYBOOL native_param_value_command;
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValue(m_fghandle, native_param_name_str, &native_param_value_command);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
paramValue = gcnew KYBOOL(native_param_value_command == 1 ? KYBOOL::KY_TRUE : KYBOOL::KY_FALSE);
break;
case PROPERTY_TYPE_REGISTER:
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValueRegister(m_fghandle, native_param_name_str, nullptr, &reg_size);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
native_param_value_reg = KY_NEW_ARRAY uint8_t[reg_size];
KYFG_GetGrabberValue_status = ::KYFG_GetGrabberValue(m_fghandle, native_param_name_str, native_param_value_reg);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
paramValue = gcnew array<System::Byte>((int)reg_size); // Creating managed array for register data
System::Runtime::InteropServices::Marshal::Copy(IntPtr(( uint8_t*) native_param_value_reg), (array<System::Byte>^)paramValue, 0, (int)reg_size ); // Copying data to managed buffer
break;
default:
throw gcnew KYFGLibException("KYFGLib Error: PROPERTY_TYPE_UNKNOWN");
break;
}
return paramValue;
}
/*
* @brief:
* Execute camera/Frame Grabber command; applicable for values of Command type.
* According to Gen<i>Cam standard naming and xml field definition and type.
* @params:
* paramName - Name of configuration parameter
*/
void Device::ExecuteCommand(const System::String^ paramName)
{
FGSTATUS KYFG_GrabberExecuteCommand_status;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
KYFG_GrabberExecuteCommand_status = ::KYFG_GrabberExecuteCommand(m_fghandle, native_param_name_str);
if (KYFG_GrabberExecuteCommand_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GrabberExecuteCommand_status);
}
return;
}
/*
* @brief:
Get camera/Frame Grabber configuration value of String type field.
* @params:
* paramName - Name of configuration parameter
*/
System::String^ Device::GetValueString(const System::String^ paramName)
{
FGSTATUS KYFG_GetGrabberValueString_status;
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Getting native char* pointer to string with param Name
const char* native_param_name_str = (const char*) (param_name_ptr.ToPointer());
char* native_param_value_str;
uint32_t stringSize = 0;
KYFG_GetGrabberValueString_status = ::KYFG_GetGrabberValueStringCopy(m_fghandle, native_param_name_str, nullptr, &stringSize); // Get string size
if (KYFG_GetGrabberValueString_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_GetGrabberValueString_status);
}
native_param_value_str = KY_NEW_ARRAY char[stringSize]; // Allocate unmanaged string
KYFG_GetGrabberValueString_status = ::KYFG_GetGrabberValueStringCopy(m_fghandle, native_param_name_str, native_param_value_str, &stringSize); // Get unmanaged string
if (KYFG_GetGrabberValueString_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValueString_status);
}
// End Of replacing block
String^ paramValue = gcnew System::String(native_param_value_str); // Create new managed String from received unmanaged char* string
delete(native_param_value_str);
return paramValue;
}
/*
* @brief:
Set camera/Frame Grabber configuration enumeration field by field name and enumeration name, according to Gen<i>Cam standard naming and xml field definition and type.
* @params:
* paramName - Name of configuration parameter
* param - Name of parameter enumeration choice
*/
void Device::SetValueEnum_ByValueName(const System::String^ paramName, const System::String^ param)
{
IntPtr param_name_ptr = Marshal::StringToHGlobalAnsi((System::String^)paramName); // Create native char* pointer to string with param name
const char* param_name_str = (const char*) (param_name_ptr.ToPointer());
IntPtr param_value_ptr = Marshal::StringToHGlobalAnsi((System::String^)param); // Create native char* pointer to string with param value
const char* param_value_str = (const char*) (param_value_ptr.ToPointer());
FGSTATUS KYFG_SetGrabberValueEnum_ByValueName_status = ::KYFG_SetGrabberValueEnum_ByValueName(m_fghandle, param_name_str, param_value_str); // Calling the func
if (KYFG_SetGrabberValueEnum_ByValueName_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_SetGrabberValueEnum_ByValueName_status);
}
Marshal::FreeHGlobal(param_name_ptr); // Release param_name_ptr
Marshal::FreeHGlobal(param_value_ptr); // Release param_value_ptr
return;
}
void Device::AuthProgramKey(array<System::Byte>^ key, int lock)
{
FGSTATUS KY_AuthProgramKey_status;
cli::pin_ptr<System::Byte> p = &key[0]; // Getting native pointer to buffer
unsigned char* native_key = p;
if (key->Length != KY_AUTHKEY_SIZE)
{
throw gcnew KYFGLibException("Authorization key should be byte array of size of 32");
}
KY_AuthKey key_struct;
for (int i=0; i<KY_AUTHKEY_SIZE; i++)
{
key_struct.secret[i] = native_key[i];
}
KY_AuthProgramKey_status = ::KY_AuthProgramKey(m_fghandle, &key_struct, lock);
if (KY_AuthProgramKey_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KY_AuthProgramKey_status);
}
return;
}
int Device::AuthVerify(array<System::Byte>^ key)
{
FGSTATUS KY_AuthVerify_status;
cli::pin_ptr<System::Byte> p = &key[0]; // Getting native pointer to buffer
unsigned char* native_key = p;
if (key->Length != KY_AUTHKEY_SIZE)
{
throw gcnew KYFGLibException("Authorization key should be byte array of size of 32");
}
KY_AuthKey key_struct;
for (int i=0; i<KY_AUTHKEY_SIZE; i++)
{
key_struct.secret[i] = native_key[i];
}
KY_AuthVerify_status = ::KY_AuthVerify(m_fghandle, &key_struct);
if (KY_AuthVerify_status != FGSTATUS_OK)
{
return 0;
}
return 1;
}
/*************************************************************************************
******************************** AuxData CallBack ********************************
*************************************************************************************/
void Device::AuxData_callback_func(KYFG_AUX_DATA* pData, void* context)
{
if (pData == nullptr)
{
return;
}
else if (pData->messageID != KYFG_AUX_MESSAGE_ID_IO_CONTROLLER)
{
return;
}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4800)
#endif // #ifdef _MSC_VER
AuxData^ aux_data = gcnew AuxData(
System::UInt32(pData->messageID),
System::Boolean(pData->version),
System::Int64(pData->dataSize),
System::UInt64(pData->u_data.io_data.masked_data),
System::UInt64(pData->u_data.io_data.timestamp));
#ifdef _MSC_VER
#pragma warning(pop)
#endif // #ifdef _MSC_VER
if (context == nullptr)
{
AuxData_callback_delegator->Invoke(aux_data, nullptr);
} else {
IntPtr managed_userContext(context);
GCHandle handle = GCHandle::FromIntPtr(managed_userContext);
Object^ obj = (Object^)handle.Target;
AuxData_callback_delegator->Invoke(aux_data, obj);
}
}
void Device::AuxDataCallbackRegister(FGAuxDataCallback^ delegator, Object^ userContext)
{
FGSTATUS KYFG_AuxDataCallbackRegister_status;
// Save the received delegator
AuxData_callback_delegator = delegator;
// Get native function pointer to Internal Callback function
Internal_AuxData_callback_delegator = gcnew InternalFGAuxDataCallback(this, &KAYA::Device::AuxData_callback_func);
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_AuxData_callback_delegator);
::FGAuxDataCallback cb_func = static_cast<::FGAuxDataCallback>(ip.ToPointer());
// Check if userContext presents and envoke KYFG_StreamBufferCallbackRegister()
// If userContext presents -> convert it to Object
if (userContext == nullptr)
{
KYFG_AuxDataCallbackRegister_status = ::KYFG_AuxDataCallbackRegister(m_fghandle, cb_func, 0);
} else {
GCHandle gc_handle = GCHandle::Alloc(userContext);
IntPtr pointer = GCHandle::ToIntPtr(gc_handle);
void* ptr = pointer.ToPointer();
KYFG_AuxDataCallbackRegister_status = ::KYFG_AuxDataCallbackRegister(m_fghandle, cb_func, ptr);
}
if (KYFG_AuxDataCallbackRegister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_AuxDataCallbackRegister_status);
}
return;
}
void Device::AuxDataCallbackRegister(FGAuxDataCallback^ delegator)
{
return Device::AuxDataCallbackRegister(delegator, nullptr);
}
void Device::AuxDataCallbackUnregister(FGAuxDataCallback^ delegator)
{
// Get Pointer to callback func
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_AuxData_callback_delegator);
::FGAuxDataCallback cb_func = static_cast<::FGAuxDataCallback>(ip.ToPointer());
// Call the unregister func
FGSTATUS KYFG_AuxDataCallbackUnregister_status = ::KYFG_AuxDataCallbackUnregister(m_fghandle, cb_func);
if (KYFG_AuxDataCallbackUnregister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_AuxDataCallbackUnregister_status);
}
return;
}
// Device Event Functions
void Device::DeviceEvent_callback_func(void* userContext, KYDEVICE_EVENT* pEvent)
{
Object^ deviceEventObj;
if (pEvent->eventId == ::KYDEVICE_EVENT_CAMERA_START_REQUEST)
{
KYDEVICE_EVENT_CAMERA_START* pEventCameraStartRequest = (KYDEVICE_EVENT_CAMERA_START*)pEvent;
deviceEventObj = gcnew DEVICE_EVENT_CAMERA_START(pEventCameraStartRequest);
}
else if (pEvent->eventId == ::KYDEVICE_EVENT_CAMERA_CONNECTION_LOST_ID)
{
KYDEVICE_EVENT_CAMERA_CONNECTION_LOST* pEventConnectionLost = (KYDEVICE_EVENT_CAMERA_CONNECTION_LOST*)pEvent;
deviceEventObj = gcnew DEVICE_EVENT_CAMERA_CONNECTION_LOST(pEventConnectionLost);
}
else if (pEvent->eventId == ::KYDEVICE_EVENT_SYSTEM_TEMPERATURE_ID)
{
KYDEVICE_EVENT_SYSTEM_TEMPERATURE* pEventTemperature = (KYDEVICE_EVENT_SYSTEM_TEMPERATURE*)pEvent;
deviceEventObj = gcnew DEVICE_EVENT_SYSTEM_TEMPERATURE(pEventTemperature);
}
else if (pEvent->eventId == ::KYDEVICE_EVENT_CXP2_HEARTBEAT_ID)
{
KYDEVICE_EVENT_CXP2_HEARTBEAT* pEventCXP2Heartbeat = (KYDEVICE_EVENT_CXP2_HEARTBEAT*)pEvent;
deviceEventObj = gcnew DEVICE_EVENT_CXP2_HEARTBEAT(pEventCXP2Heartbeat);
}
else if (pEvent->eventId == ::KYDEVICE_EVENT_CXP2_EVENT_ID)
{
KYDEVICE_EVENT_CXP2_EVENT* pEventCXP2Event = (KYDEVICE_EVENT_CXP2_EVENT*)pEvent;
deviceEventObj = gcnew DEVICE_EVENT_CXP2_EVENT(pEventCXP2Event);
}
else if (pEvent->eventId == ::KYDEVICE_EVENT_GENCP_EVENT_ID)
{
KYDEVICE_EVENT_GENCP_EVENT* pEventGencpEvent = (KYDEVICE_EVENT_GENCP_EVENT*)pEvent;
deviceEventObj = gcnew DEVICE_EVENT_GENCP_EVENT(pEventGencpEvent);
}
else if (pEvent->eventId == ::KYDEVICE_EVENT_GIGE_EVENTDATA_ID)
{
KYDEVICE_EVENT_GIGE_EVENTDATA* pEventGigeEventData = (KYDEVICE_EVENT_GIGE_EVENTDATA*)pEvent;
deviceEventObj = gcnew DEVICE_EVENT_GIGE_EVENTDATA(pEventGigeEventData);
}
else
{
deviceEventObj = nullptr;
}
if (userContext == nullptr)
{
DeviceEvent_callback_delegator->Invoke(/*userContext*/nullptr, /*DeviceEventStruct*/deviceEventObj);
}
else
{
IntPtr managed_userContext(userContext);
GCHandle handle = GCHandle::FromIntPtr(managed_userContext);
Object^ obj = (Object^)handle.Target;
DeviceEvent_callback_delegator->Invoke(/*userContext*/obj, /*DeviceEventStruct*/deviceEventObj);
}
return;
}
// done
void Device::EventCallBackRegister(DeviceEventCallBack^ deviceEventDelegator, Object^ userContext)
{
FGSTATUS KYDeviceEventCallBackRegister_status;
// Save the received delegator
DeviceEvent_callback_delegator = deviceEventDelegator;
// Get native function pointer to Internal Callback function
Internal_DeviceEvent_callback_delegator = gcnew InternalDeviceEventCallBack(this, &KAYA::Device::DeviceEvent_callback_func);
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_DeviceEvent_callback_delegator);
::KYDeviceEventCallBack cb_func = static_cast<::KYDeviceEventCallBack>(ip.ToPointer());
if (userContext == nullptr)
{
KYDeviceEventCallBackRegister_status = ::KYDeviceEventCallBackRegister(m_fghandle, cb_func, 0);
}
else {
GCHandle gc_handle = GCHandle::Alloc(userContext);
IntPtr pointer = GCHandle::ToIntPtr(gc_handle);
void* ptr = pointer.ToPointer();
KYDeviceEventCallBackRegister_status = ::KYDeviceEventCallBackRegister(m_fghandle, cb_func, ptr);
}
if (KYDeviceEventCallBackRegister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYDeviceEventCallBackRegister_status);
}
return;
}
void Device::EventCallBackRegister(DeviceEventCallBack^ deviceEventDelegator)
{
return Device::EventCallBackRegister(deviceEventDelegator, nullptr);
}
void Device::EventCallBackUnregister(DeviceEventCallBack^ deviceEventDelegator)
{
// Get Pointer to callback func
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_DeviceEvent_callback_delegator);
::KYDeviceEventCallBack cb_func = static_cast<::KYDeviceEventCallBack>(ip.ToPointer());
// Call the unregister func
FGSTATUS KYDeviceEventCallBackUnregister_status = ::KYDeviceEventCallBackUnregister(m_fghandle, cb_func);
if (KYDeviceEventCallBackUnregister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYDeviceEventCallBackUnregister_status);
}
return;
}
/*
* @brief: Status of specific device physical port regarding connectivity with remote device (i.e camera)
* @params:
* port - Frame Grabber port index
* size - Size in bytes of buffer to read
@return:
* portStatus - Object, that represents a status of the device.
*/
PORT_STATUS Device::GetPortStatus(int port)
{
::PORT_STATUS port_status_native;
FGSTATUS KYFG_ReadPortstatus_status = ::KYFG_GetPortStatus(m_fghandle, port, &port_status_native);
if (KYFG_ReadPortstatus_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_ReadPortstatus_status);
}
PORT_STATUS portStatus = PORT_STATUS(port_status_native);
return portStatus;
}
/**
* @brief Send Event Message as specified by GenCP for CLHS, or EVENTDATA message for 10GigE
* @params:
* port - Frame Grabber port index
* eventId - id of the event message
* buffer - buffer data to write
*/
void Device::DevicePortSendEventMessage(int port, System::UInt32 eventId, array<System::Byte>^ buffer)
{
uint32_t native_eventId = eventId;
cli::pin_ptr<System::Byte> p = &buffer[0];
unsigned char* native_buffer = p;
uint32_t buf_size = buffer->Length;
// Call the unregister func
FGSTATUS KYFG_DevicePortSendEventMessage_status = ::KYFG_DevicePortSendEventMessage(m_fghandle, port, native_eventId, native_buffer, buf_size);
if (KYFG_DevicePortSendEventMessage_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_DevicePortSendEventMessage_status);
}
return;
}
}

View File

@@ -0,0 +1,67 @@
#pragma once
#include "KYFGLib.h"
#include "KYFGLib.NET.h"
#include <cliext/map>
#include "KY_Parameters.h"
namespace KAYA
{
public ref class Device : public IDevice
{
private:
FGHANDLE m_fghandle;
typedef cliext::map<System::String^, System::Type^> EnumParametersMap;
EnumParametersMap m_EnumParameterMap;
void AuxData_callback_func(KYFG_AUX_DATA* pData, void* context);
FGAuxDataCallback^ AuxData_callback_delegator;
InternalFGAuxDataCallback^ Internal_AuxData_callback_delegator;
void DeviceEvent_callback_func(void* userContext, KYDEVICE_EVENT* pEvent);
DeviceEventCallBack^ DeviceEvent_callback_delegator;
InternalDeviceEventCallBack^ Internal_DeviceEvent_callback_delegator;
System::Type^ GetEnumParameterType(const char* native_param_name_str);
KY_Parameters^ m_KY_Parameters;
public:
Device(FGHANDLE h);
virtual System::Collections::Generic::List<ICamera^>^ CameraScan();
virtual System::Collections::Generic::List<ICamera^>^ UpdateCameraList();
virtual void Close();
virtual Object^ GetValueIntMaxMin(const System::String^ paramName);
virtual Object^ GetValueFloatMaxMin(const System::String^ paramName);
virtual Object^ GetValue(const System::String^ paramName);
virtual System::String^ GetValueString(const System::String^ paramName);
virtual void SetValue(const System::String^ paramName, Object^ paramValue);
virtual void ExecuteCommand(const System::String^ paramName);
virtual void SetValueEnum_ByValueName(const System::String^ paramName, const System::String^ param);
virtual void WritePortBlock(int port, System::UInt64 address, array<System::Byte>^ buffer);
virtual void WritePortReg(int port, System::UInt64 address, System::UInt32 data);
virtual array<System::Byte>^ ReadPortBlock(int port, System::UInt64 address, System::UInt32 size);
virtual System::UInt32 ReadPortReg(int port, System::UInt64 address);
virtual PORT_STATUS GetPortStatus(int port);
virtual void AuthProgramKey(array<System::Byte>^ key, int lock);
virtual int AuthVerify(array<System::Byte>^ key);
virtual void AuxDataCallbackRegister(FGAuxDataCallback^ delegator, Object^ userContext);
virtual void AuxDataCallbackRegister(FGAuxDataCallback^ delegator);
virtual void AuxDataCallbackUnregister(FGAuxDataCallback^ delegator);
virtual void EventCallBackRegister(DeviceEventCallBack^ deviceEventDelegator, Object^ userContext);
virtual void EventCallBackRegister(DeviceEventCallBack^ deviceEventDelegator);
virtual void EventCallBackUnregister(DeviceEventCallBack^ deviceEventDelegator);
virtual void DevicePortSendEventMessage(int port, System::UInt32 eventId, array<System::Byte>^ buffer);
};
}

View File

@@ -0,0 +1,311 @@
#include "Stdafx.h"
#include "KYFGLib.NET.h"
#include "KYFGLib_Stream.h"
#include "KYFGLib_StreamBuffer.h"
#include "KYFGLib_utils.h"
//using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
namespace KAYA
{
/*
Int64 Stream::GetSize()
{
Int64 size = ::KYFG_StreamGetSize(handle);
if (size == -1 )
{
throw gcnew KYFGLibException("KYFGLibException: Some error has occured");
}
return size;
}
*/
/*
int Stream::GetFrameIndex()
{
int index = ::KYFG_StreamGetFrameIndex(handle);
if (index == -1 )
{
throw gcnew KYFGLibException("KYFGLibException: Some error has occured");
}
return index;
}
*/
Object^ Stream::GetPtr(System::UInt32 frame_idx)
{
void* native_data_ptr = ::KYFG_StreamGetPtr(handle, frame_idx);
if (native_data_ptr == nullptr)
{
throw gcnew KYFGLibException("KYFGLibException: Some error has occured");
}
IntPtr managed_data(native_data_ptr);
GCHandle handle = GCHandle::FromIntPtr(managed_data);
Object^ obj = (Object^)handle.Target;
return obj;
}
//Note: If StreamBuffer becomes statefull, use map, don't create object every time
void Stream::Stream_callback_func(STREAM_BUFFER_HANDLE streamHandle, void* userContext)
{
StreamBuffer^ stream_buffer;
if (streamHandle == 0)
{
stream_buffer = nullptr;
}
else {
stream_buffer = gcnew StreamBuffer(streamHandle);
}
if (userContext == nullptr)
{
Stream_callback_delegator->Invoke(stream_buffer, nullptr);
} else {
IntPtr managed_userContext(userContext);
GCHandle handle = GCHandle::FromIntPtr(managed_userContext);
Object^ obj = (Object^)handle.Target;
Stream_callback_delegator->Invoke(stream_buffer, obj);
}
}
/*
* @brief: Register a camera runtime acquisition callback function. The callback (userFunc) will be called upon new received frame, of a valid stream
* @params:
* delegator - Delegstor to callback function
* userContext - User defined context to identify the received callback
*/
void Stream::BufferCallbackRegister(StreamBufferCallback^ delegator, Object^ userContext)
{
FGSTATUS KYFG_CallbackRegister_status;
// Save the received delegator
Stream_callback_delegator = delegator;
// Get native function pointer to Internal Callback function
Internal_Stream_callback_delegator = gcnew InternalStreamBufferCallback(this, &KAYA::Stream::Stream_callback_func);
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_Stream_callback_delegator);
::StreamBufferCallback cb_func = static_cast<::StreamBufferCallback>(ip.ToPointer());
// Check if userContext presents and envoke KYFG_StreamBufferCallbackRegister()
// If userContext presents -> convert it to Object
if (userContext == nullptr)
{
KYFG_CallbackRegister_status = ::KYFG_StreamBufferCallbackRegister(handle, cb_func, 0);
} else {
GCHandle gc_handle = GCHandle::Alloc(userContext);
IntPtr pointer = GCHandle::ToIntPtr(gc_handle);
void* ptr = pointer.ToPointer();
KYFG_CallbackRegister_status = ::KYFG_StreamBufferCallbackRegister(handle, cb_func, ptr);
}
if (KYFG_CallbackRegister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_CallbackRegister_status);
}
return;
}
/*
* @brief: Register a camera runtime acquisition callback function. The callback (userFunc) will be called upon new received frame, of a valid stream
* @params:
* delegator - Delegstor to callback function
* userContext - User defined context to identify the received callback
*/
void Stream::BufferCallbackRegister(StreamBufferCallback^ delegator)
{
return Stream::BufferCallbackRegister(delegator, nullptr);
}
void Stream::BufferCallbackUnregister(StreamBufferCallback^ delegator)
{
IntPtr ip = Marshal::GetFunctionPointerForDelegate(Internal_Stream_callback_delegator);
::StreamBufferCallback cb_func = static_cast<::StreamBufferCallback>(ip.ToPointer());
FGSTATUS KYFG_StreamBufferCallbackUnregister_status = ::KYFG_StreamBufferCallbackUnregister(handle, cb_func);
if (KYFG_StreamBufferCallbackUnregister_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_StreamBufferCallbackUnregister_status);
}
return;
}
void Stream::Delete()
{
FGSTATUS KYFG_StreamDelete_status = ::KYFG_StreamDelete(handle);
if (KYFG_StreamDelete_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_StreamDelete_status);
}
return;
}
Object^ Stream::GetInfo(KY_STREAM_INFO_CMD info)
{
FGSTATUS KYFG_StreamGetInfo_status;
Object^ managed_data;
// Retrieve which Type and Size the data, we are going to request
size_t pInfoSize;
KY_DATA_TYPE pInfoType;
size_t native_data;
KYFG_StreamGetInfo_status = ::KYFG_StreamGetInfo(handle, (::KY_STREAM_INFO_CMD)info, &native_data, &pInfoSize, &pInfoType);
managed_data = gcnew System::UInt64(native_data);
return managed_data;
}
AuxData^ Stream::GetAux(int frame)
{
FGSTATUS KYFG_StreamGetAux_status;
KYFG_AUX_DATA pData;
AuxData^ aux_data;
KYFG_StreamGetAux_status = ::KYFG_StreamGetAux(handle, frame, &pData); // Call to the native function
switch(pData.messageID)
{
// Currently pData.messageID must be equal to 11, otherwise we return Exception
case KYFG_AUX_MESSAGE_ID_IO_CONTROLLER:
// Create managed AuxData
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4800)
#endif // #ifdef _MSC_VER
aux_data = gcnew AuxData(
System::UInt32(pData.messageID),
System::Boolean(pData.version),
System::Int64(pData.dataSize),
System::UInt64(pData.u_data.io_data.masked_data),
System::UInt64(pData.u_data.io_data.timestamp));
#ifdef _MSC_VER
#pragma warning(pop)
#endif // #ifdef _MSC_VER
break;
default:
throw gcnew KYFGLibException("Internal Error: AuxData id unknown. Interrupt: " + pData.messageID);
break;
}
return aux_data; // Return managed
}
/*
* @brief:
* This function is used to allocate and announce a buffer and bind it to a stream.
* @params:
* nBufferSize - The size of allocated memory.
* @return:
* buff_handle_managed - Allocated Stream Buffer
*/
IStreamBuffer^ Stream::BufferAllocAndAnnounce(System::UInt64 nBufferSize)
{
FGSTATUS KYFG_BufferAllocAndAnnounce_status;
STREAM_BUFFER_HANDLE buff_handle_native;
KYFG_BufferAllocAndAnnounce_status = ::KYFG_BufferAllocAndAnnounce(handle, (size_t)nBufferSize, nullptr, &buff_handle_native); // Calling the original function
StreamBuffer^ buff_handle_managed = gcnew StreamBuffer(buff_handle_native); // Creating a managed StreamBuffer
return buff_handle_managed;
}
/*
* @brief:
* This function is used to announce a buffer allocated by user and bind it to a stream.
* @params:
* buffer - User allocated byte array, which will be used to hold frame data
* @return:
* buff_handle_managed - Appropriate stream buffer
*/
IStreamBuffer^ Stream::BufferAnnounce(array<System::Byte>^ buffer)
{
FGSTATUS KYFG_BufferAnnounce_status;
STREAM_BUFFER_HANDLE buff_handle_native;
cli::pin_ptr<System::Byte> p = &buffer[0]; // Getting native pointer to buffer
unsigned char* native_buffer = p;
uint64_t buf_size = buffer->Length; // Retrieving buffer Length
KYFG_BufferAnnounce_status = ::KYFG_BufferAnnounce(handle, native_buffer, (size_t)buf_size, nullptr, &buff_handle_native); // Getting native buffer handle
StreamBuffer^ buff_handle_managed = gcnew StreamBuffer(buff_handle_native); // Creating a managed StreamBuffer
return buff_handle_managed;
}
/*
* @brief:
* This function is used to announce a buffer allocated by user and bind it to a stream.
* @params:
* buffer - User allocated byte array, which will be used to hold frame data
* @return:
* buff_handle_managed - Appropriate stream buffer
*/
IStreamBuffer^ Stream::BufferAnnounce(System::IntPtr buffer, uint64_t size)
{
FGSTATUS KYFG_BufferAnnounce_status;
STREAM_BUFFER_HANDLE buff_handle_native;
//cli::pin_ptr<System::Byte> p = &buffer[0]; // Getting native pointer to buffer
unsigned char* native_buffer = static_cast<unsigned char*>(buffer.ToPointer());
uint64_t buf_size = size; // Retrieving buffer Length
KYFG_BufferAnnounce_status = ::KYFG_BufferAnnounce(handle, native_buffer, (size_t)buf_size, nullptr, &buff_handle_native); // Getting native buffer handle
StreamBuffer^ buff_handle_managed = gcnew StreamBuffer(buff_handle_native); // Creating a managed StreamBuffer
return buff_handle_managed;
}
/*
* @brief:
* Revoke and delete resources of previously announced buffer. The buffer should be announced to 'streamHandle' stream, acquisition should be stopped
* @params:
* streamBufferHandle - handle of previously announced buffer.
*/
void Stream::BufferRevoke(STREAM_BUFFER_HANDLE streamBufferHandle)
{
FGSTATUS KYFG_BufferRevoke_status;
KYFG_BufferRevoke_status = ::KYFG_BufferRevoke(handle, streamBufferHandle);
if (KYFG_BufferRevoke_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferRevoke_status);
}
}
/*
* @brief:
* This function moves all frame buffers bound to specified stream from one queue to another queue.
* @params:
* srcQueue - Source queue.
* dstQueue - Destination queue.
*/
void Stream::BufferQueueAll(KY_ACQ_QUEUE_TYPE srcQueue, KY_ACQ_QUEUE_TYPE dstQueue)
{
FGSTATUS KYFG_BufferQueueAll_status;
KYFG_BufferQueueAll_status = ::KYFG_BufferQueueAll(handle, KY_ACQ_QUEUE_TYPE_man2nat(srcQueue), KY_ACQ_QUEUE_TYPE_man2nat(dstQueue));
if (KYFG_BufferQueueAll_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferQueueAll_status);
}
return;
}
}

View File

@@ -0,0 +1,44 @@
#pragma once
#include "KYFGLib.h"
#include "KYFGLib.NET.h"
namespace KAYA
{
public ref class Stream : IStream
{
private:
STREAM_HANDLE handle;
void Stream_callback_func(STREAM_BUFFER_HANDLE streamHandle, void* userContext);
StreamBufferCallback^ Stream_callback_delegator;
InternalStreamBufferCallback^ Internal_Stream_callback_delegator;
public:
Stream(STREAM_HANDLE h): handle(h) {}
STREAM_HANDLE get_handle() { return handle; }
virtual void BufferCallbackRegister(StreamBufferCallback^ delegator, Object^ userContext);
virtual void BufferCallbackRegister(StreamBufferCallback^ delegator);
virtual void BufferCallbackUnregister(StreamBufferCallback^ delegator);
/* virtual System::Int64 GetSize(); */
/* virtual int GetFrameIndex(); */
virtual Object^ GetPtr(System::UInt32 buffIndex);
virtual void Delete();
virtual Object^ GetInfo(KY_STREAM_INFO_CMD info);
virtual AuxData^ GetAux(int frame);
virtual IStreamBuffer^ BufferAllocAndAnnounce(System::UInt64 nBufferSize);
virtual IStreamBuffer^ BufferAnnounce(array<System::Byte>^ pBuffer); // Deprecated
virtual IStreamBuffer^ BufferAnnounce(System::IntPtr pBuffer, uint64_t size);
virtual void BufferRevoke(STREAM_BUFFER_HANDLE streamBufferHandle);
virtual void BufferQueueAll(KY_ACQ_QUEUE_TYPE srcQueue, KY_ACQ_QUEUE_TYPE dstQueue);
};
}

View File

@@ -0,0 +1,136 @@
#include "Stdafx.h"
#include "KYFGLib.NET.h"
#include "KYFGLib_StreamBuffer.h"
#include "KYFGLib_utils.h"
//using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
namespace KAYA
{
int StreamBuffer::GetFrameIndex()
{
uint32_t frame_idx = 0;
FGSTATUS KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle,::KY_STREAM_BUFFER_INFO_ID, &frame_idx, nullptr, nullptr);
if (KYFG_BufferGetInfo_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferGetInfo_status);
}
return frame_idx;
}
Object^ StreamBuffer::GetPtr()
{
void* native_data_ptr = nullptr;
//size_t pInfoSize;
//KY_DATA_TYPE pInfoType;
Object^ managed_data;
// Retrieve pInfoSize and pInfoType of the Buffer
FGSTATUS KYFG_BufferGetInfo_status;
// Get the Base address of the buffer memory.
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, ::KY_STREAM_BUFFER_INFO_BASE, &native_data_ptr, nullptr, nullptr);
if (KYFG_BufferGetInfo_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferGetInfo_status);
}
managed_data = gcnew IntPtr(native_data_ptr);
return managed_data;
}
Object^ StreamBuffer::GetInfo(KY_STREAM_BUFFER_INFO_CMD info)
{
FGSTATUS KYFG_BufferGetInfo_status;
Object^ managed_data;
// Retrieve which Type and Size the data, we are going to request
// size_t pInfoSize;
KY_DATA_TYPE pInfoType;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, nullptr, nullptr, &pInfoType);
if (KYFG_BufferGetInfo_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferGetInfo_status);
}
// Get the Base address of the buffer memory.
switch(pInfoType)
{
case ::KY_DATATYPE_PTR:
// TODO: Verify with Michael:
void* data;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, &data, nullptr, nullptr);
managed_data = gcnew IntPtr(data);
break;
case ::KY_DATATYPE_SIZET:
size_t data_size_t;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, &data_size_t, nullptr, nullptr);
managed_data = gcnew System::UInt64(data_size_t);
break;
case ::KY_DATATYPE_UINT64:
uint64_t data_uint_64;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, &data_uint_64, nullptr, nullptr);
managed_data = gcnew System::UInt64(data_uint_64);
break;
case ::KY_DATATYPE_UINT32:
uint32_t data_uint_32;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, &data_uint_32, nullptr, nullptr);
managed_data = gcnew System::UInt32(data_uint_32);
break;
case ::KY_DATATYPE_FLOAT64:
double data_double;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, &data_double, nullptr, nullptr);
managed_data = gcnew System::Double(data_double);
break;
case ::KY_DATATYPE_STREAM_HANDLE:
uint32_t data_uint_32_sHandle;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, &data_uint_32_sHandle, nullptr, nullptr);
managed_data = gcnew System::UInt32(data_uint_32_sHandle);
break;
case ::KY_DATATYPE_CAMHANDLE:
uint32_t data_uint_32_cHandle;
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, (::KY_STREAM_BUFFER_INFO_CMD)info, &data_uint_32_cHandle, nullptr, nullptr);
managed_data = gcnew System::UInt32(data_uint_32_cHandle);
break;
default:
throw gcnew KYFGLibException("KYFGLib Error: Data type is invalid");
break;
}
if (KYFG_BufferGetInfo_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferGetInfo_status);
}
return managed_data;
}
System::UInt64^ StreamBuffer::getSize()
{
size_t buffer_size;
FGSTATUS KYFG_BufferGetInfo_status;
// Get the Size of the buffer.
KYFG_BufferGetInfo_status = ::KYFG_BufferGetInfo(handle, ::KY_STREAM_BUFFER_INFO_SIZE, &buffer_size, nullptr, nullptr);
if (KYFG_BufferGetInfo_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferGetInfo_status);
}
return gcnew System::UInt64(buffer_size);
}
void StreamBuffer::BufferToQueue(KY_ACQ_QUEUE_TYPE dstQueue)
{
FGSTATUS KYFG_BufferToQueue_status;
KYFG_BufferToQueue_status = ::KYFG_BufferToQueue(handle, KY_ACQ_QUEUE_TYPE_man2nat(dstQueue));
if (KYFG_BufferToQueue_status != FGSTATUS_OK)
{
throw gcnew KYFGLibException(KYFG_BufferToQueue_status);
}
}
}

View File

@@ -0,0 +1,33 @@
#pragma once
#include "KYFGLib.h"
#include "KYFGLib.NET.h"
namespace KAYA
{
//TODO:
/* As long as this class is stateles it's ok remain as it
/ If the class becomes statefull, we should find all the places in program, when we call gcnew StreamBuffer
/ and hash the results, cause state is associates with a specific instance of class
/ As option we can create a lazy map (on the go) of all buffers of a specific stream in Stream class
/ or static map in this class (StreamBuffer)
*/
public ref class StreamBuffer : IStreamBuffer
{
private:
STREAM_BUFFER_HANDLE handle;
public:
StreamBuffer(STREAM_BUFFER_HANDLE h): handle(h) {}
STREAM_BUFFER_HANDLE get_handle() { return handle; }
virtual int GetFrameIndex();
virtual Object^ GetPtr();
virtual Object^ GetInfo(KY_STREAM_BUFFER_INFO_CMD info);
virtual System::UInt64^ getSize();
virtual void BufferToQueue(KY_ACQ_QUEUE_TYPE dstQueue);
};
}

View File

@@ -0,0 +1,39 @@
#include "stdafx.h"
#include "KYFGLib_utils.h"
namespace KAYA
{
/* @breaf Gets native KY_ACQ_QUEUE_TYPE from managed
* @params
* managed_queue_type - Managed KY_ACQ_QUEUE_TYPE parameter
* @return
* native_queue_type - Native KY_ACQ_QUEUE_TYPE parameter
*/
::KY_ACQ_QUEUE_TYPE KY_ACQ_QUEUE_TYPE_man2nat (KY_ACQ_QUEUE_TYPE managed_queue_type)
{
::KY_ACQ_QUEUE_TYPE native_queue_type;
switch(managed_queue_type)
{
case KY_ACQ_QUEUE_INPUT: // buffers in INPUT queue are ready to be filled with data
native_queue_type = ::KY_ACQ_QUEUE_INPUT;
break;
case KY_ACQ_QUEUE_OUTPUT: // buffers in OUTPUT queue have been filled and awaiting user processing
native_queue_type = ::KY_ACQ_QUEUE_OUTPUT;
break;
case KY_ACQ_QUEUE_UNQUEUED: // buffers in UNQUEUED set have been anounced but are inactive for acquisition mechanisem. By default all buffers are placed in UNQUEUED set
native_queue_type = ::KY_ACQ_QUEUE_UNQUEUED;
break;
case KY_ACQ_QUEUE_AUTO : // buffers in AUTO queue are managed automatically, in a cyclic matter, without the need for user to re-queue them
native_queue_type = ::KY_ACQ_QUEUE_AUTO;
break;
default:
throw gcnew KYFGLibException("Invalid KY_ACQ_QUEUE_TYPE argument");
break;
}
return native_queue_type;
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "Stdafx.h"
#include "KYFGLib.NET.h"
namespace KAYA
{
::KY_ACQ_QUEUE_TYPE KY_ACQ_QUEUE_TYPE_man2nat (KY_ACQ_QUEUE_TYPE managed_queue_type);
}

View File

@@ -0,0 +1,104 @@
#include "stdafx.h"
#include "KY_Parameters.h"
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
namespace KAYA
{
KY_Parameters::KY_Parameters(KYHANDLE kyhandle)
:m_kyhandle(kyhandle)
{
/*
// Create Base Assembly Objects
#ifdef _DEBUG
System::String ^ assemblyNameString = "KYFGLibNetReflectionD";
#else
System::String ^ assemblyNameString = "KYFGLibNetReflection";
#endif
AppDomain^ appDomain = AppDomain::CurrentDomain;
AssemblyName^ asmName = gcnew AssemblyName(assemblyNameString);
AssemblyBuilder^ asmBuilder = appDomain->DefineDynamicAssembly(asmName, AssemblyBuilderAccess::Run);
// Create Module
m_modBuilder = asmBuilder->DefineDynamicModule(asmName + "_DynaModule");
*/
}
System::Type ^ KY_Parameters::GetEnumParameterType(const char * native_param_name_str)
{
//System::String ^ enumNameString = gcnew System::String(native_param_name_str);
System::String ^ enumNameString = System::String::Format("KY{0:X8}_{1}", CAMHANDLE(m_kyhandle), gcnew System::String(native_param_name_str));
EnumParametersMap::iterator it = m_EnumParameterMap.find(enumNameString);
if (it != m_EnumParameterMap.end())
{
return it->second;
}
FGSTATUS KYFG_GetGrabberValue_status;
EnumParameterDefinition* pEnumParameterDefinition = KY_NEW EnumParameterDefinition();
EnumParameterDefinition& enumParameterDefinition = *pEnumParameterDefinition;
KYFG_GetGrabberValue_status = ::KY_GetEnumParameterDefinition(m_kyhandle, native_param_name_str, enumParameterDefinition);
if (KYFG_GetGrabberValue_status != FGSTATUS_OK) // Error check
{
throw gcnew KYFGLibException(KYFG_GetGrabberValue_status);
}
// From Device::GetEnumParameterType()
// Create Base Assembly Objects
#ifdef _DEBUG
System::String ^ assemblyNameString = "KYFGLibNetReflectionD";
#else
System::String ^ assemblyNameString = "KYFGLibNetReflection";
#endif
AppDomain^ appDomain = AppDomain::CurrentDomain;
AssemblyName^ asmName = gcnew AssemblyName(assemblyNameString);
AssemblyBuilder^ asmBuilder = appDomain->DefineDynamicAssembly(asmName, AssemblyBuilderAccess::Run);
// Create Module and Enumeration Builder Objects
ModuleBuilder^ modBuilder = asmBuilder->DefineDynamicModule(asmName + "_DynaModule");
EnumBuilder^ enumBuilder = modBuilder->DefineEnum(enumNameString, TypeAttributes::Public, int64_t::typeid);
// end of From Device::GetEnumParameterType()
//
//// Enumeration Builder Object
////EnumBuilder^ enumBuilder = m_modBuilder->DefineEnum(enumNameString, TypeAttributes::Public, int64_t::typeid);
//EnumBuilder^ enumBuilder = m_ReflectionInstance->GetModBuilder()->DefineEnum(enumNameString, TypeAttributes::Public, int64_t::typeid);
//
for (const auto& enumEntry : enumParameterDefinition.m_Entries)
{
System::String ^ entryNameString = gcnew System::String(enumEntry.second.name.c_str());
enumBuilder->DefineLiteral(entryNameString, enumEntry.second.value);
}
Type^ theType = enumBuilder->CreateType();
m_EnumParameterMap[enumNameString] = theType;
delete pEnumParameterDefinition;
return theType;
}
KY_Parameters::KYFGLibNetReflection::KYFGLibNetReflection()
{
// Create Base Assembly Objects
#ifdef _DEBUG
System::String ^ assemblyNameString = "KYFGLibNetReflectionD";
#else
System::String ^ assemblyNameString = "KYFGLibNetReflection";
#endif
AppDomain^ appDomain = AppDomain::CurrentDomain;
AssemblyName^ asmName = gcnew AssemblyName(assemblyNameString);
AssemblyBuilder^ asmBuilder = appDomain->DefineDynamicAssembly(asmName, AssemblyBuilderAccess::Run);
// Create Module
m_modBuilder = asmBuilder->DefineDynamicModule(asmName + "_DynaModule");
}
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include "KYFGLib.h"
#include "KYFGLib.NET.h"
#include <cliext/map>
namespace KAYA
{
public ref class KY_Parameters
{
private:
KYHANDLE m_kyhandle;
typedef cliext::map<System::String^, System::Type^> EnumParametersMap;
EnumParametersMap m_EnumParameterMap;
//::System::Reflection::Emit::ModuleBuilder^ m_modBuilder;
ref class KYFGLibNetReflection
{
public:
KYFGLibNetReflection();
::System::Reflection::Emit::ModuleBuilder^ GetModBuilder()
{
return m_modBuilder;
}
private:
::System::Reflection::Emit::ModuleBuilder^ m_modBuilder;
}; //ref class KYFGLibNetReflection
static KYFGLibNetReflection^ m_ReflectionInstance = gcnew KYFGLibNetReflection;
public:
KY_Parameters(KYHANDLE kyhandle);
System::Type^ GetEnumParameterType(const char* native_param_name_str);
};
}//namespace KAYA

View File

@@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// KYFGLib.NET.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,7 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once

View File

@@ -0,0 +1,22 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
#define TEXTFILE 256
#define IDR_DEVENV_TEXTFILE 101
#ifdef KAYA_DEVENV_ACTIVE
#include "../../version_internal.h"
#include "../KYLogger/KYBase.h"
#endif