//==========================================================================//
//                                                                          //
//	C# - ICube-InterfaceClass               								//
//                                                                          //
//  Copyright (C) 2018 ,Net gmbh                                            //
//  Version 1.0.0.6
//                                                                          //
//==========================================================================//

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ICubeSDKSample
{
    class ICube
    {    
#if  _WIN64
    public const string DLL_NAME = "ICubeSDK64.dll";
#else
    public const string DLL_NAME = "ICubeSDK.dll";
#endif

    // Global Defines

    public const int		IC_SUCCESS			= 0;
    public const int		IC_ERROR			= 1;

    public const int		IC_IF_NOT_OPEN		= -1;
    public const int		IC_WRONG_PARAM		= -2;
    public const int		IC_OUT_OF_MEMORY	= -3;
    public const int		IC_ALREADY_DONE		= -4;
    public const int		IC_WRONG_CLOCK_VAL	= -5;
    public const int		IC_COM_LIB_INIT    	= -6;
    public const int		IC_NOT_IF_STARTED  	= -7;
    public const int        IC_WRONG_ROI_ID  	= -8;
    public const int	    IC_IF_NOT_ENABLED  	= -9;		
    public const int        IC_COLOR_CAM_ONLY   = -10;
    public const int        IC_DRIVER_VERSION   = -11;
    public const int        IC_D3D_INIT         = -12;
    public const int        IC_BAD_POINTER      = -13;
    public const int        IC_ERROR_FILE_SIZE  = -14;
    public const int		IC_RECONNECTION_ACTIVE = -15;
    public const int		IC_USB_REQUEST_FAIL = -16;
    public const int	    IC_RESOURCE_IN_USE  = -17;
    public const int		IC_DEVICE_GONE		= -18;
    public const int		IC_DLL_MISMATCH		= -19;
    public const int	    IC_WRONG_FW_VERSION	= -20;
    public const int	    IC_NO_RGB_CALLBACK  = -21;
    public const int	    IC_NO_USB30_CAMERA	= -22;
    public const int        IC_ERR_FIX_RELATION = -23;     
    public const int 		IC_CRC_CONFIG_DATA	= -24;	
    public const int        IC_CONFIG_DATA      = -25;	
    public const int		IC_ERR_START_PNP	= -26;
    public const int	    IC_INVALID_CAM_TYPE	= -27;		
    public const int        IC_NOT_IF_STREAMING = -28;
    public const int        IC_USB_STARTUP = -29;     // USB transfer error during start aquisition

    // Video Mode definitions
    // (used with: ICubeSDK_SetMode,ICubeSDK_GetMode)

    public const int		MODE_320x240		= 0;
    public const int		MODE_640x480		= 1;
    public const int		MODE_752x480		= 2;
    public const int		MODE_800x600		= 3;
    public const int		MODE_1024x768		= 4;
    public const int		MODE_1280x1024		= 5;
    public const int		MODE_1600x1200		= 6;
    public const int		MODE_2048x1536		= 7;
    public const int		MODE_2592x1944	    = 8;
    public const int        MODE_3840x2748      = 9;
    public const int        MODE_1920x1200      = 10;

    // BinSkip definitions
    // (used with: ICubeSDK_SetBinSkip,ICubeSDK_GetBinSkip,ICubeSDK_GetBinSkipList)

    public const int     MODE_SKIP		     = 0;
    public const int     MODE_BIN		     = 1;
    public const int     BIN_SKIP_OFF    	 = 0;
    public const int     BIN_SKIP_2ND_PIXEL	 = 1;
    public const int     BIN_SKIP_4TH_PIXEL	 = 2;

    // Parameter definitions 
    // (used with: ICubeSDK_SetCamParameter,ICubeSDK_GetCamParameter,
    // ICubeSDK_GetCamParameterRange,ICubeSDK_GetParamAuto,ICubeSDK_SetParamAuto,
    // ICubeSDK_SetParamAutoDef,ICubeSDK_SetParamOnePush)

    // Measure field definitions
    // (used with REG_MEASURE_FIELD_AE)

    public const int MEASUREFIELD_100	     = 2;	// 100% (full frame)
    public const int MEASUREFIELD_60		 = 1;	// 60%
    public const int MEASUREFIELD_30		 = 0;	// 30%

    // Shutter definitions
    // (used with REG_SHUTTER)

    public const int SHUTTER_ROLLING = 0;
    public const int SHUTTER_GLOBAL_RESET = 1;
    public const int SHUTTER_GLOBAL = 2;
    
    // Parameter ON||OFF definitions

    public const int OFF = 0;
    public const int ON = 1;

    // Trigger invert definitions
    // (used with REG_TRIGGER_INVERT)

    public const int FALLING_EDGE = 0;
    public const int RISING_EDGE = 1;

    // Software trigger mode definitions
    // (used with REG_SW_TRIG_MODE)

    public const int DELAYED_TRIGGER_RETURN  = 0;   // camera checks for frame arrival (default),
									                // ICubeSDK_SetTrigger(..,TRIG_SW_DO) returns this status
    public const int IMMEDIATE_TRIGGER_RETURN = 1;	// no camera check

    // Data transmission definitions
    // (used with REG_DATA_TRANSMISSION)

    public const int IS_8BIT = 0; // (default)  
    public const int IS_16BIT = 1;          

    // Bayer Conversion definitions
    // (used with REG_BAYER_CONVERSION)

    public const int DE_BAYER_3x3			 =0;          
    public const int DE_BAYER_5x5			 =1; // (default)           

    // Gamma definitions
    // (used with REG_GAMMA_MODE)

    public const int GAMMA_MODE_DEFAULT   	 = 2;	// (default)   
    public const int GAMMA_MODE_sRGB  		 = 1;
    public const int GAMMA_MODE_ITU709       = 0;	// (HDTV)

    // Graphic definitions 
    // (used with REG_GRAPHIC_MODE)

    public const int DISPLAY_GDI			 = 0;
    public const int DISPLAY_D3D             = 1;

    // Camera parameters definitions

    public const int REG_BRIGHTNESS			= 1;	// write: only when REG_COLOR_PROCCESSING enabled, read: always
    public const int REG_CONTRAST			= 2;	// write: only when REG_COLOR_PROCCESSING enabled, read: always
    public const int REG_GAMMA				= 3;    // write: only when REG_GAMMA_ENABLE enabled, read: always
    public const int REG_FLIPPED_V			= 4;	// (ON||OFF); OFF (default)
    public const int REG_FLIPPED_H			= 5;	// (ON||OFF); OFF (default)
    public const int REG_WHITE_BALANCE		= 6;	// (one push)
    public const int REG_EXPOSURE_TIME		= 7;    // all models
    public const int REG_EXPOSURE_TARGET	= 8;	// sets the target-value for the auto exposure algorithm 
    public const int REG_RED				= 9;	// only for color models; RGB Gain value
    public const int REG_GREEN				= 10;	// only for color models
    public const int REG_BLUE				= 11;	// only for color models
    public const int REG_BLACKLEVEL			= 12;   // sensor blacklevel
    public const int REG_GAIN				= 13;	// sensor gain
    public const int REG_COLOR				= 14;	// (ON||OFF) read: color || bw model
    public const int REG_PLL				= 15;	// all models
    public const int REG_STROBE_LENGHT		= 16;	// length of strobe pulse output (msec)
    public const int REG_STROBE_DELAY		= 17;   // delay before strobe pulse is executed (msec)
    public const int REG_TRIGGER_DELAY		= 18;   // delay before hardware trigger is executed (msec)
    public const int REG_SATURATION			= 19;	// only for color models, when REG_COLOR_PROCCESSING enabled 
    public const int REG_COLOR_ENHANCE		= 20;	// obsolet
    public const int REG_TRIGGER_INVERT		= 21;	// (FALLING_EDGE (default) || RISING_EDGE)
    public const int REG_RECONNECTIONS		= 22;	// get the value of usb reconnections
    public const int REG_MEASURE_FIELD_AE	= 23;   // measure field for auto exposure
    public const int REG_AVI_STATE			= 24;	// get the avi stream save status (ON||OFF)
    public const int REG_FOCUS				= 25;   // not implemented yet
    public const int REG_SHUTTER            = 26;   // (4133CU/BU,4203CU/BU)
    public const int REG_ROI_ID             = 27;   // (4133CU/BU,4203CU/BU,fpga board cameras)
    public const int REG_ROI_CYCLE          = 28;   // (4133CU/BU,4203CU/BU) number of repetitions of the particular roi

    public const int REG_DEFECT_COR         = 43;   // (4133CU/BU,4203CU/BU) DefectPixelCorrection (ON||OFF); OFF(default)
    public const int REG_BAD_FRAME          = 81;   // read bad frame count (also possible with ICubeSDK_GetBrokenFrames)
    public const int REG_GOOD_FRAME         = 82;   // read good frame count (also possible with ICubeSDK_GetGoodFrames)
    public const int REG_SW_TRIG_MODE		= 94;   // (DELAYED_TRIGGER_RETURN (default) || IMMEDIATE_TRIGGER_RETURN)
    public const int REG_ROI_FPGA_ONE_FRAME	= 96;   // (fpga board only) pseudo frame format (ON||OFF)	
    public const int REG_CALLBACK_BR_FRAMES	= 97;	// Broken frames also triggering the callback function (ON||OFF); OFF(default)
    public const int REG_FGPA_VBLANKING		= 98;	// (fpga board only) output Frame blanking
    public const int REG_FGPA_HBLANKING		= 99;   // (fpga board only) output Frame blanking
    public const int REG_FGPA_CLK_DIVIDER	= 100;  // (fpga board only) output clock divider (ON||OFF)
    public const int REG_FGPA_ON_BOARD		= 101;  // check if camera has fpga board (ON||OFF)

    public const int REG_SET_GPIO			= 102;  // bit masked: XXXX X J3-7 J3-6 J3-5
    public const int REG_GET_GPIO			= 103;  // bit masked: XXXX X J3-7 J3-6 J3-5
    public const int REG_SET_GPIO_MODE		= 104;	// (0==Input || 1==Output),bit masked: XXXX X J3-7 J3-6 J3-5

    public const int REG_MASK_ROI_ID         = 105; // roi_id masked in buffersize of callback 

    public const int REG_RED_OFFSET			= 106;	// only for color models; RGB offset value
    public const int REG_GREEN_OFFSET		= 107;  // only for color models
    public const int REG_BLUE_OFFSET		= 108;  // only for color models

    public const int REG_HUE				= 109;	// only for color models; write: only when REG_COLOR_PROCCESSING enabled, read: always
    public const int REG_COLOR_CORRECTION	= 110;  // (ON||OFF) ColorCorrection matrix; OFF (default)
    public const int REG_GAMMA_ENABLE		= 111;  // (ON||OFF) en/disable gamma module to save CPU load; ON (default)
    public const int REG_GAMMA_MODE			= 112;  // only for color models ; write: only when REG_GAMMA_ENABLE enabled, read: always
    public const int REG_INVERT_PIXEL		= 113;  // (ON||OFF)  bw cams only
    public const int REG_TNR				= 115;  // (ON||OFF)  only for color models, temporal noise reduction
    public const int REG_BAYER_CONVERSION	= 116;  // only for color models; choose different debayering
    public const int REG_COLOR_PROCESSING	= 117;	// (ON||OFF) en/disable color proc module module to save CPU load;  ON (default)	
    public const int REG_USB_SPEED			= 118;  // 0: usb port is high speed, 1: usb port is super speed capable (useful for super speed camera)
    public const int REG_DEVICE_SPEED		= 119;  // 0: camera is high speed, 1: camera is super speed capable
    public const int REG_DATA_TRANSMISSION  = 120;  // 0: 8 bit per pixel, 1: 16 bit per pixel in raw mode
    public const int REG_SIGNIFICANT_BITS	= 125;  // number of significant bits in pixel 
    public const int REG_GRAPHIC_MODE       = 126;  // GDI (default)|| D3D 
    public const int REG_EDGE_ENHANCEMENT	= 128;  // (ON||OFF) edge enhancement; OFF (default)
    public const int REG_EDGE_ENHANCEMENT_GAIN = 129; // 0-128 (default 64)
    public const int REG_SENSOR_STROBE      = 132;  // (4133CU/BU,4203CU/BU) sensor strobe (ON||OFF); OFF(default)

    public const int REG_TRIG_TIMEOUT       = 138;	// (super speed cameras) default: 20000 msec
    public const int REG_PIPE_TIMEOUT_MODE  = 139;	// (super speed cameras) overwrite default configuration
    public const int REG_RESET_CAMERA		= 140;  // reset the camera
    public const int REG_DISCONNECTIONS		= 141;  // get the value of camera disconnections
    public const int REG_XACT_RECOVER_MODE  = 142;  // (superspeed camera only) recover transaction errors
    public const int REG_RESET_TO_DEFAULT   = 143;  // reset all camera parameters to default values

    public const int REG_TRANSFER_BUF_CNT   = 145;  // adjustment of usb streaming buffers
    public const int REG_SW_TRIG_WD_MODE    = 146;  // (ON||OFF); ON(default)
    public const int REG_AQU_FRAMERATE      = 147;  // (2234CU/BU) get/set the framerate
    public const int REG_SENSOR_STROBE_DELAY= 148;  // (4133CU/BU,4203CU/BU) only	
    public const int REG_SENSOR_OVERLAPPED  = 149;  // (4133CU/BU,4203CU/BU) only 
    public const int REG_TRIG_DELAY_DIVIDER = 150;  // (4133CU/BU,4203CU/BU) 

    // Parameter definitions
    // (used with: ICubeSDK_GetCamParameterRange)

    public struct PARAM_PROPERTY{
        public int bEnabled;
        public int bAuto;
        public int bOnePush;
        public uint nDef;
        public uint nMin;
        public uint nMax;	
    };

    public const int DEFAULT_GAMMA = 64;

    // Parameter definitions (float value)
    // (used with: ICubeSDK_GetExposureRange)
    // values in [msec]

    public struct PARAM_PROPERTY_f{
        public int bEnabled;
        public int bAuto;
        public int bOnePush;
        public float nDef;
        public float nMin;
        public float nMax;	
    };

    // Roi definitions
    // (used with: REG_ROI_ID)

    // ROI ID: (4133CU/BU)
    // SIMR: Single Integration Multiple Roi  (4133CU/BU only)
    // 1, 2 or 4 areas of interest to be acquired within the same integrated image
    // MIMR: Multible Integration Multiple Roi (4133CU/BU only)
    // 
    public const int ROI_ID_1_2	        = 0;	// SIMR (4133CU/BU only)
    public const int ROI_ID_1_1	        = 1;	// default mode for all models (1st roi)
    public const int ROI_ID_2	        = 2;   // MIMR additonal (4133CU/BU only)
    public const int ROI_ID_3	        = 3;
    public const int ROI_ID_4	        = 4;

    // ROI ID: (all cameras with fpga board)
    //
    public const int ROI_ID_0	        = 0;	// fpga input size
    public const int ROI_ID_1	        = 1;	// fpga output size roi 1
    public const int ROI_ID_2_	        = 2;   
    public const int ROI_ID_3_	        = 3;
    public const int ROI_ID_4_	        = 4;
    public const int ROI_ID_5           = 5;

// ROI ID: (all cameras without fpga board,except 4133CU/BU)
// only one roi available (roi1)

    // (used with: ICubeSDK_SetResolution, ICubeSDK_GetResolution)

    public struct ROI_PROPERTY{
        public int bEnabled;
        public int nXRes;
        public int nYRes;
        public int nXPos;
        public int nYPos;
    }

    // Due to usb packet size, the Region of interest size has limitations.
    // The horizontal and vertical Roi-size must be dividable by 4. 

    public const int ROI_STEP_SIZE = 4;

    // (11000CU/BU only)
    // Due to sensor limitations, 
    // the horizontal and vertical Roi-size must be dividable by 8. 

    public const int  ROI_STEP_SIZE_11000 = 8;


    // (used with: ICubeSDK_GetCamParameterRange)

    public struct ROI_RANGE_PROPERTY{
        public int nXMin;
        public int nXMax;
        public int nYMin;
        public int nYMax;
    }

    // Trigger definitions
    // (used with: ICubeSDK_SetTrigger, ICubeSDK_GetTrigger)

    public const int TRIG_SW_START = 0;
    public const int TRIG_SW_DO = 1;
    public const int TRIG_HW_START = 2;
    public const int TRIG_STOP = 3;
    public const int TRIG_SW_START_2 = 4;    // GRR mode (1500CU/BU,1300CU,NET3_11000BU/CU)
    public const int TRIG_HW_START_2 = 5;    // GRR mode (1500CU/BU,1300CU,NET3_11000BU/CU)

    // Versions definitions
    // (used with: ICubeSDK_GetVersion)

    public const int DLL_VERSION = 0;
    public const int API_VERSION = 1;

    // Callback definitions
    // (used with: ICubeSDK_SetCallback)

    public const int CALLBACK_RAW = 0;
    public const int CALLBACK_RGB = 1;


    // DisplayMode definitions
    // (used with: ICubeSDK_SetDisplayMode)

    public const int DISPLAY_NORMAL = 0;
    public const int DISPLAY_FIT_TO_WINDOW = 1;
    public const int DISPLAY_RECT = 2;

    public struct DISP_PROPERTY
    {
        public int left;
        public int top;
        public int right;
        public int bottom;
    }; 


    // AVI stream definitions
    // (used with: ICubeSDK_SaveAvi)

    public const int AVI_DIB = 0;	// currently, only this avi mode is supported
  
    // Name length definitions
    // (used with: ICubeSDK_GetName,ICubeSDK_GetSerialNum,ICubeSDK_GetVersion,ICubeSDK_GetFWVersion)

    public const int NETCAM_NAME_LENGTH		= 14;	// length of the name string
    public const int NETCAM_SERIAL_LENGTH	= 10;	// length of the serial number string
    public const int NETCAM_VERSION_LENGTH  = 9;	// length of the version string

    // IsOpen definitions
    // (used with: ICubeSDK_IsOpen)

    public const int IS_CLOSED = 0;
    public const int IS_OPEN = 1;

    // IsStarted definitions
    // (used with: ICubeSDK_IsStarted)

    public const int IS_STOPPED = 0;
    public const int IS_STARTED = 1;

    // event definitions
    // (used with: ICubeSDK_SetCallbackEx)

    public const int EVENT_NEW_FRAME		= 0;		
    public const int EVENT_DEV_DISCONNECTED	= 1;	// a camera is disconnected	
    public const int EVENT_DEV_RECONNECTED	= 2;	// a camera is reconnected		
    public const int EVENT_USB_TRANSFER_FAILED = 3;	// a usb transaction error occured during streaming

    // pipe timeout mode definitions
    // (used with: REG_PIPE_TIMEOUT_MODE)

    public const int MODE_TIMEOUT_NONE  = 0;	
    public const int MODE_TIMEOUT_ALL   = 1;
    public const int MODE_TIMEOUT_PART  = 2;

    // parameter set definitions
    // (used with: ICubeSDK_CamParameterSet())

    public const int PARAMETER_LOAD_TO_FILE	    = 0;	// load from camera to .ini-file
    public const int PARAMETER_LOAD_FROM_FILE   = 1;	// load from .ini-file to camera 


    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Camera control functions
    //
    //////////////////////////////////////////////////////////////////////////////
    
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_Init();
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_Open(int nCamIndex);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_Close(int nCamIndex);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_IsOpen(int nCamIndex);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_IsOpenEx(int nCamIndex);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetCallback(int nCamIndex,int nMode,IntPtr pCallbackFunc,int pCBContext);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetCallbackEx(int nCamIndex, int nMode, IntPtr pCallbackFuncEx, int pCBContext);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_Start(int nCamIndex, IntPtr ImgHandle, int Preview, int Callback);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_IsStarted(int nCamIndex);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_Stop(int nCamIndex);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetSize(int nCamIndex, ref int pnXRes, ref int pnYRes);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetName(int nCamIndex,StringBuilder Name);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetBrokenFrames(int nCamIndex,ref int pnFrames);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetGoodFrames(int nCamIndex,ref int pnFrames);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetDisplayMode(int nCamIndex,int nMode,DISP_PROPERTY property);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Version functions
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern void ICubeSDK_GetVersion(int nType,StringBuilder pVersion);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetFWVersion(int nCamIndex,StringBuilder pVersion);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetSerialNum(int nCamIndex, StringBuilder pVersion);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          ROI functions
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetResolution(int nCamIndex,ref ROI_PROPERTY property);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetResolution(int nCamIndex,ref ROI_PROPERTY property);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetResolutionRange(int nCamIndex,ref ROI_RANGE_PROPERTY property);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetResolutionParam(int nCamIndex,IntPtr ImgHandle,int Preview,int Callback);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Mode functions
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetMode(int nCamIndex,int nMode);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetMode(int nCamIndex,ref int pMode);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetModeList(int nCamIndex,ref int pLength,int[] pList);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Bin Skip functions
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetBinSkip(int nCamIndex ,int nParameter,int nMode);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetBinSkip(int nCamIndex ,ref int nParameter,int nMode);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetBinSkipList(int nCamIndex ,int nMode,ref int pLenght,ref int pList);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Save functions
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SaveToFile(int nCamIndex, string Name);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SaveAvi(int nCamIndex ,string Name,int nMode,int nTimeInSecs);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Trigger functions
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetTrigger(int nCamIndex ,int nMode);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetTrigger(int nCamIndex ,ref int nMode);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Parameter functions 
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetCamParameter(int nCamIndex ,int Type,uint Value);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetCamParameter(int nCamIndex, int Type, ref uint Value);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetCamParameterRange(int nCamIndex ,int Type,ref PARAM_PROPERTY property);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_CamParameterSet(int nCamIndex, int nCmd, string nParam);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //          Exposure functions 
    //          This functions can be used alternativly to parameter functions,
    //          for manipulating exposure only. Parameter Value is in milli-seconds.
    //          Be aware that every change of clock
    //          and width will lead to different exposure values
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetExposure(int nCamIndex ,float Value);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetExposure(int nCamIndex ,ref float Value);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetExposureRange(int nCamIndex ,ref PARAM_PROPERTY_f property);

    //////////////////////////////////////////////////////////////////////////////'
    //
    //       for Parameter functions and Exposure functions (auto||manual,one-push)
    //
    //////////////////////////////////////////////////////////////////////////////

    [DllImport(DLL_NAME)] public static extern int ICubeSDK_GetParamAuto(int nCamIndex ,int Type,ref int bAuto);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetParamAuto(int nCamIndex ,int Type,int bAuto);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetParamAutoDef(int nCamIndex ,int Type);
    [DllImport(DLL_NAME)] public static extern int ICubeSDK_SetParamOnePush(int nCamIndex ,int Type);
       
   
    }
}
