//***************************************************************************
//   (C) 2005 STEMMER IMAGING
//
///  \file TLIClientDummy.cpp
///     TLI Dummy Client Interface implementation
///  \brief 
///     TLI Client Interface
///  \author    Rupert Stelz (STEMMER IMAGING)
///  \version   0.1
///  \date      2005
//
//***************************************************************************
  

// TLIClientDummy.dll GenICam TransportLayer Dummy Client 
// Copyright (C) 2005 STEMMER IMAGING
// This library is free software; you can redistribute it and/or modify it under the 
// terms of the GNU Lesser General Public License as published by the Free Software 
// Foundation; either version 2.1 of the License, or (at your option) any later 
// version. This library is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
// more details.
// You should have received a copy of the GNU Lesser General Public License along 
// with this library; if not, write to the Free Software Foundation, Inc., 59 Temple 
// Place, Suite 330, Boston, MA 02111-1307 USA 



#include <GCError.h>

#include <TLI/TLI.h>

#include <genapi/Exception.h>
#include <genapi/Types.h>
#include <GenApi/RegisterSetHelper.h>
#include <GenApi/Pointer.h>
#include <GenApi/NodeMapDyn.h>
#include <GenApi/Category.h>

namespace GenICam {
  namespace TL   {
    namespace Glue   {


    
    //******************************************************************
    ///  \par G_TLSetCallback
    ///       Add a CallBack to the internal list of call back functions
    ///  \param [in] hTL                TL Handle
    ///  \param [in] pCB                Pointer to a callback
    ///  \param [in] pPrivate           Private pointer to data passed to the callback
    ///  \retval                        GC_ERROR
    ///
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_TLSetCallback ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, TL_HANDLE hTL, TL_Callback pCB, void *pPrivate);

    //******************************************************************
    ///  \par G_TLRemoveCallback
    ///       Remove a TL Callbackfunction from teh internal call back list
    ///  \param [in] hTL                TL Handle
    ///  \param [in] pCB                Pointer to the Callback function
    ///  \retval                        GC_ERROR
    ///
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_TLRemoveCallback ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, TL_HANDLE hTL, TL_Callback pCB );





    //******************************************************************
    ///  \par G_DevGetNumDataStreams
    ///       Inquire the number of available data streams for a specific device
    ///  \param [in] hDev               Dev Handle
    ///  \param [out] piNumChannel      number of available channels on this device
    ///  \retval                        GC_ERROR
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DevGetNumDataStreams ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DEV_HANDLE hDev, uint32_t *piNumChannel);

    //******************************************************************
    ///  \par G_DevCreateDataStream
    ///         Create an DataStream for a give Device Object
    ///  \param [in]  hDev               Dev Handle
    ///  \param [in]  iChannel           Channel Number
    ///  \param [out] hDS                ImageStream Handle
    ///  \retval                         GC_ERROR
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DevCreateDataStream ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DEV_HANDLE hDev, uint32_t iChannel, DS_HANDLE *hDS);

    //******************************************************************
    ///  \par G_DevGetName
    ///       Return a unique name for the Device
    ///  \param [in]      hDev         Handle of the Device
    ///  \param [in,out]  pInfo        Pointer to DevInfo Structure to recieve the device information
    ///  \param [in,out]  iSize        Size of the buffer in bytes
    ///  \retval                       GC_ERROR <br>
    ///                                 < 0 signals an error <br>
    ///                                 see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DevGetInfo ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DEV_HANDLE hDev, DEVINFO *pInfo, uint32_t *iSize);

    //******************************************************************
    ///  \par G_DevSetCallback
    ///       Add a callback entry tp the internal callback list of the device
    ///  \param [in]  hDev         Handle of the Device
    ///  \param [in]  pCB          Pointer to the callback function
    ///  \param [in]  pPrivate     Pointer to private data passed to the callback
    ///  \retval                       GC_ERROR <br>
    ///                                 < 0 signals an error <br>
    ///                                 see GC_ERROR description for further details

    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DevSetCallback ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DEV_HANDLE hDev, Dev_Callback pCB, void *pPrivate);

    //******************************************************************
    ///  \par G_DevRemoveCallback
    ///       Remove a callback entry from the internal callback list of the device
    ///  \param [in]  hDev         Handle of the Device
    ///  \param [in]  pCB          Pointer to the callback function
    ///  \retval                   GC_ERROR <br>
    ///                              < 0 signals an error <br>
    ///                              see GC_ERROR description for further details

    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DevRemoveCallback ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DEV_HANDLE hDev, Dev_Callback pCB );


    //******************************************************************
    ///  \par G_TLCloseDevice
    ///       Close a single device and destoy all internal data structures
    ///  \param [in] hDev               Dev Handle
    ///  \retval                       GC_ERROR <br>
    ///                                 < 0 signals an error <br>
    ///                                 see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DevClose ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DEV_HANDLE hDev );

     
    //******************************************************************
    ///  \par G_DSAnnounceBuffer
    ///           Announce a Frame Buffer to the ImageStream
    ///  \param [in]  hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in]  pBuffer            Pointer to a user allocated memory buffer
    ///  \param [in]  iSize              Size of \c pBuffer in Bytes
    ///  \param [in]  pPrivate           Private Pointer, passed to user on buffer arrival
    ///  \param [out] iID                ??
    ///  \retval                         GC_ERROR <br>
    ///                                   < 0 signals an error <br>
    ///                                   see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSAnnounceBuffer ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, void *pBuffer, uint32_t iSize, void *pPrivate, uint32_t *iID );

    //******************************************************************
    ///  \par G_DSRevokeBuffer
    ///       Remove a memory buffer from the internal buffer list <br>
    ///       was DSRemoveBuffer until Grenoble
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] iID                ID of the buffer
    ///  \param [out]pBuffer            Pointer to the memory buffer
    ///  \retval                        GC_ERROR <br>
    ///                                  < 0 signals an error <br>
    ///                                  see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSRevokeBuffer ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, uint32_t iID, void **pBuffer, void **pPrivate);

    //******************************************************************
    ///  \par G_DSAllocAndAnnounceBuffer
    ///       Queue a Buffer for Acquisition using it's ID <br>
    ///       The ID is returned by the \c DSAnnounceBuffer function <br>
    ///       was DSQueueBufferByID until Grenoble
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] iSize              Size of the Buffer to allocate in Bytes
    ///  \param [in] pPrivate           Pointer to private Data passed to the App on delivery
    ///  \param [out] pBuffer           Pointer to the Buffer memory
    ///  \param [out] iID               ID of the Buffer
    ///  \retval                       GC_ERROR <br>
    ///                                 < 0 signals an error <br>
    ///                                 see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR      GC_CALLTYPE G_DSAllocAndAnnounceBuffer( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, uint32_t iSize, void *pPrivate, void **pBuffer, uint32_t *iID );

    //******************************************************************
    ///  \par G_DSQueueBuffer
    ///       Queue a Buffer for Acquisition using it's ID <br>
    ///       The ID is returned by the \c DSAnnounceBuffer function <br>
    ///       was DSQueueBufferByID until Grenoble
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] iID                ID of the Buffer
    ///  \retval                        GC_ERROR <br>
    ///                                  < 0 signals an error <br>
    ///                                  see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSQueueBuffer ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, uint32_t iID);

    //******************************************************************
    ///  \par G_DSFlushQueue
    ///       Remove all queued buffers from the internal acquisition queue and place it into the output queue <br>
    ///       was DSDiscardQueue until Grenoble
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \retval                        GC_ERROR
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSFlushQueue ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, ACQ_QUEUE_TYPE QueueType );

    //******************************************************************
    ///  \par G_DSStartAcquisition
    ///       Start an acquisition (single or continous depending on the 
    ///       \c iAcquisitionFlags)  <br>
    ///       was DSStartAcquisition until Grenoble
    ///  \param [in] hDS                  Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] iAcquisitionFlags    Image Acquisition Flags see ACQ_START_FLAGS
    ///  \param [in] iNumImagesToAcquire  Number of Images to Acquire
    ///  \retval                          GC_ERROR <br>
    ///                                     < 0 signals an error <br>
    ///                                     see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR  GC_CALLTYPE G_DSStartAcquisition ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, ACQ_START_FLAGS iAcquisitionFlags, uint64_t iNumImagesToAcquire );

    //******************************************************************
    ///  \par G_DSWaitForBuffer
    ///       Wait for a new data to arrive. This function implies that
    ///       a.) there are queued buffers DSQueueBufferById or DSQueueBufferByPointer
    ///       and b.) an DSStartAcqusition has been called
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] iTimeoutMs         Timeout in ms
    ///  \param [in] iWaitFlags         Wait Flags see ACQ_WAIT_FLAGS
    ///  \param [in] AcqInfo            a structure, allocated by the user and filled by the TLI Cient
    ///  \param [in] ppPrivate          Private Pointer, Passed in when buffer is queued
    ///  \retval                        GC_ERROR <br>
    ///                                  < 0 signals an error <br>
    ///                                  see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSWaitForBuffer ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, uint32_t iTimeoutMs, ACQ_WAIT_FLAGS iWaitFlags,  ACQ_INFO *AcqInfo, void **ppPrivate);

    //******************************************************************
    ///  \par G_DSStopAcquisition
    ///       Stop acquisition
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] Flags              acquisition flags
    ///  \retval                        GC_ERROR <br>
    ///                                  < 0 signals an error <br>
    ///                                  see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSStopAcquisition( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap,   DS_HANDLE hDS, ACQ_STOP_FLAGS Flags );


    //******************************************************************
    ///  \par G_DSGetStatus
    ///       Get status information from the acquisition proscess
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] iCmd               Command, see ACQ_STATUS_CMD for further information
    ///  \param [in] pBuffer            Pointer to a buffer to recieve the information 
    ///  \param [in] iSize              Size of the buffer in bytes
    ///  \retval                        GC_ERROR <br>
    ///                                  < 0 signals an error <br>
    ///                                  see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSGetStatus ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, ACQ_STATUS_CMD iCmd, void *pBuffer, uint64_t *iSize);

    //******************************************************************
    ///  \par G_DSGetBufferInfo
    ///       Get static information on a specific Buffer
    ///  \param [in] hDS                Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \param [in] iID                Buffer Id
    ///  \param [in,out] BufInfo        Pointer to a BUF_INFO struct, which will be filled in the function
    ///  \param [in] iSize              Size of the buffer in bytes
    ///  \retval                        GC_ERROR <br>
    ///                                  < 0 signals an error <br>
    ///                                  see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSGetBufferInfo ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, uint32_t iID, BUF_INFO *BufInfo, uint32_t *iSize );


    //******************************************************************
    ///  \par G_DSClose
    ///       Destroy this data stream
    ///  \param [in] hDS               Image Stream Handle, Created with GC::TL::DevCreateImageStream
    ///  \retval                       GC_ERROR <br>
    ///                                 < 0 signals an error <br>
    ///                                 see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSClose ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS);

    //******************************************************************
    ///  \par G_DevQueryCustomFeature
    ///       Query Device for custom Freature
    ///  \param [in] hDev               Dev Handle
    ///  \param [in] pInBuf             Input Buffer 
    ///  \param [in] iInSize            Size of Input Buffer in Bytes
    ///  \param [out] pOutBuf           Output Buffer, The Buffer is supplied by the caller
    ///  \param [in,out] iOutSize       input: Size of the provided buffer,output: size of the used buffer, if a zero is 
    ///                                 passed to this parameter the required output buffer size is returned
    ///  \retval                       GC_ERROR <br>
    ///                                 < 0 signals an error <br>
    ///                                 see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT GC_ERROR GC_CALLTYPE G_DevQueryCustomFeature  ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, Client::DEV_HANDLE hDev, void *pInBuf, uint32_t iInSize, void *pOutBuf, uint32_t *iOutSize);
    
    //******************************************************************
    ///  \par DSGetBufferID
    ///       Return the ID of a buffer with the specified index. Note that this index is dynamic and might change with 
    ///       additional added and / or removed buffers.
    ///  \param [in] hDS                Data Stream Handle, Created with GC::TL::DevCreateDataStream
    ///  \param [in] iIndex             zero based index of all announced buffers.
    ///  \param [out] iID               Buffer Id
    ///  \retval                        GC_ERROR <br>
    ///                                  < 0 signals an error <br>
    ///                                  see GC_ERROR description for further details
    ///
    ///  \note
    EXTERN_C GC_IMPORT_EXPORT  GC_ERROR GC_CALLTYPE G_DSGetBufferID ( GenApi::CNodeMap *TLNodeMap, GenApi::CNodeMap *DevNodeMap, DS_HANDLE hDS, uint32_t iIndex, uint32_t *iID);
   
    }
  }
}