ChunkAdapterDcam.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //-----------------------------------------------------------------------------
  2. // (c) 2004 by Basler Vision Technologies
  3. // Section: Vision Components
  4. // Project: GenApi
  5. // Author: Fritz Dierks
  6. // $Header$
  7. //
  8. // License: This file is published under the license of the EMVA GenICam Standard Group.
  9. // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
  10. // If for some reason you are missing this file please contact the EMVA or visit the website
  11. // (http://www.genicam.org) for a full copy.
  12. //
  13. // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
  14. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
  17. // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. // POSSIBILITY OF SUCH DAMAGE.
  24. //-----------------------------------------------------------------------------
  25. /**
  26. \file
  27. \brief Declaration of the CChunkAdapterDcam class.
  28. */
  29. #ifndef GENAPI_CHUNKADAPTERDCAM_H
  30. #define GENAPI_CHUNKADAPTERDCAM_H
  31. #include <Base/GCTypes.h>
  32. #include <GenApi/ChunkAdapter.h>
  33. #include <GenApi/Compatibility.h>
  34. namespace GENAPI_NAMESPACE
  35. {
  36. void GENAPI_DECL SET_GUID(GUID& name, uint32_t l, uint16_t w1, uint16_t w2, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7, uint8_t b8);
  37. // make sure everything is properly packed
  38. # pragma pack(push, 1)
  39. typedef struct DCAM_CHUNK_TRAILER
  40. {
  41. GUID ChunkID ;
  42. uint32_t ChunkLength ;
  43. uint32_t InverseChunkLength ;
  44. } DCAM_CHUNK_TRAILER;
  45. typedef struct DCAM_CHECKSUM
  46. {
  47. uint32_t CRCChecksum ;
  48. } DCAM_CHECKSUM;
  49. // restore the previous packing
  50. # pragma pack(pop)
  51. /* ------------------------------------------- */
  52. //! Connects a chunked DCAM buffer to a node map
  53. class GENAPI_DECL CChunkAdapterDcam : public CChunkAdapter
  54. {
  55. public:
  56. //! Constructor
  57. CChunkAdapterDcam(INodeMap* pNodeMap = NULL, int64_t MaxChunkCacheSize = -1);
  58. //! Destructor
  59. virtual ~CChunkAdapterDcam();
  60. //! Checks if a buffer contains chunks in a known format
  61. virtual bool CheckBufferLayout(uint8_t *pBuffer, int64_t BufferLength);
  62. //! Attaches a buffer to the matching ChunkPort
  63. virtual void AttachBuffer(uint8_t *pBuffer, int64_t BufferLength, AttachStatistics_t *pAttachStatistics = NULL);
  64. //! Checks if buffer has a CRC attached
  65. bool HasCRC(uint8_t *pBuffer, int64_t BufferLength);
  66. //! Checks CRC sum of buffer
  67. bool CheckCRC(uint8_t *pBuffer, int64_t BufferLength);
  68. protected:
  69. //! Checks the CRC of a buffer
  70. uint32_t CRC16(const unsigned char *pData, uint32_t nbyLength );
  71. //! Checks the CRC of a buffer
  72. bool CheckBuffer(const unsigned char* pData, uint32_t nbyLength );
  73. };
  74. }
  75. #endif // GENAPI_CHUNKADAPTERDCAM_H