00001 //----------------------------------------------------------------------------- 00002 // (c) 2006-8 by Basler Vision Technologies 00003 // Section: Vision Components 00004 // Project: GenApi 00005 // Author: Fritz Dierks 00006 // $Header$ 00007 // 00008 // License: This file is published under the license of the EMVA GenICam Standard Group. 00009 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. 00010 // If for some reason you are missing this file please contact the EMVA or visit the website 00011 // (http://www.genicam.org) for a full copy. 00012 // 00013 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" 00014 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00015 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00016 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP 00017 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00018 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00019 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00020 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00021 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 // POSSIBILITY OF SUCH DAMAGE. 00024 //----------------------------------------------------------------------------- 00031 #ifndef GENAPI_CHUNKPORT_H 00032 #define GENAPI_CHUNKPORT_H 00033 00034 #include <GenApi/Pointer.h> 00035 #include <GenApi/IPortConstruct.h> 00036 #include <GenApi/INodeMap.h> 00037 00038 #ifdef _MSC_VER 00039 # pragma warning(push) 00040 # pragma warning(disable: 4251) // GenApi::CChunkPort::m_ptrPort' : class 'GenApi::CPointer<T>' needs to have dll-interface 00041 #endif 00042 00043 namespace GENAPI_NAMESPACE 00044 { 00045 00050 class GENAPI_DECL CChunkPort : public IPortConstruct 00051 { 00052 00053 public: 00054 00056 CChunkPort(IPort* pPort = NULL); 00057 00059 virtual ~CChunkPort(); 00060 00061 //------------------------------------------------------------- 00062 // IPortConstruct implementation 00063 //------------------------------------------------------------- 00064 00066 virtual EAccessMode GetAccessMode() const; 00067 00069 virtual EInterfaceType GetPrincipalInterfaceType() const; 00070 00072 virtual void Read(void *pBuffer, int64_t Address, int64_t Length); 00073 00075 virtual void Write(const void *pBuffer, int64_t Address, int64_t Length); 00076 00078 virtual void SetPortImpl(GENAPI_NAMESPACE::IPort* pPort); 00079 00081 virtual EYesNo GetSwapEndianess() 00082 { 00083 return No; 00084 } 00085 00086 //--------------------------------------------------------------- 00087 // Implementation 00088 //--------------------------------------------------------------- 00089 00090 // Invalidates the chunk port node 00091 void InvalidateNode(); 00092 00093 //------------------------------------------------------------- 00094 // Initializing 00095 //------------------------------------------------------------- 00096 00098 bool AttachPort(GENAPI_NAMESPACE::IPort* pPort); 00099 00101 void DetachPort(); 00102 00104 void AttachChunk(uint8_t *pBaseAddress, int64_t ChunkOffset, int64_t Length, bool Cache); 00105 00107 void DetachChunk(); 00108 00110 int GetChunkIDLength() 00111 { 00112 return m_ChunkIDLength; 00113 } 00114 00116 bool CheckChunkID(uint8_t* pChunkIDBuffer, int ChunkIDLength); 00117 00119 bool CheckChunkID(uint64_t ChunkID); 00120 00122 void UpdateBuffer(uint8_t *pBaseAddress); 00123 00125 void ClearCache(); 00126 protected: 00127 00128 CLock& GetLock() const 00129 { 00130 if (!m_ptrPort.IsValid()) 00131 throw RUNTIME_EXCEPTION("The event port is not attached to a node"); 00132 00133 return m_ptrPort->GetNodeMap()->GetLock(); 00134 } 00135 00136 //------------------------------------------------------------- 00137 // Member variables 00138 //------------------------------------------------------------- 00139 00141 uint8_t *m_pBaseAddress; 00142 00144 int64_t m_ChunkOffset; 00145 00147 int64_t m_Length; 00148 00150 int64_t m_LengthAlloc; 00151 00153 CNodePtr m_ptrPort; 00154 00156 uint8_t *m_pChunkIDBuffer; 00157 00159 int m_ChunkIDLength; 00160 00162 uint8_t *m_pChunkData; 00163 00165 bool m_CacheData; 00166 00168 uint64_t m_ChunkIDNumber; 00169 00171 bool m_ChunkIDNumberValid; 00172 }; 00173 00174 } 00175 00176 #ifdef _MSC_VER 00177 # pragma warning(pop) 00178 #endif 00179 00180 #endif // GENAPI_CHUNKPORT_H