// This fuction adds events to an open Burst File void AddEvBFile(PZdabWriter* const b){ // Write out the data if(b->WriteBank( PZdabFile::GetBank((nZDAB*) burstev[burstptr.head]), kZDABindex)){ fprintf(stderr, "Error writing zdab to burst file\n"); alarm(30, "Stonehenge: Error writing zdab to burst file", 0); } // Drop the data from the buffer memset(burstev[burstptr.head], 0, MAXSIZE*sizeof(uint32_t)); bursttime[burstptr.head] = 0; AdvanceHead(); bcount++; }
// This function drops old events from the buffer once they expire void UpdateBuf(uint64_t longtime, int BurstLength){ // The case that the buffer is empty if(burstptr.head==-1) return; // Normal Case int BurstTicks = BurstLength*50000000; // length in ticks while((bursttime[burstptr.head] < longtime - BurstTicks) && (burstptr.head!=-1)){ bursttime[burstptr.head] = 0; memset(burstev[burstptr.head], 0, MAXSIZE*sizeof(uint32_t)); AdvanceHead(); // Reset to empty state if we have emptied the queue if(burstptr.head==burstptr.tail){ burstptr.head=-1; burstptr.tail=-1; } } }
/// \brief Writes entries to the buffer. /// /// \param [in] pSource The source values which will be written into the buffer. /// \param uiCount The number of elements to write. /// /// \return true if it the values could all be written, false if the buffer is full. /// bool Write(const T* pSource, unsigned int uiCount = 1) { if (uiCount > 0) { if (uiCount + m_uiAvailable > Size) { return false; } // Don't write past the end of the array int uiElementsToWrite = hkvMath::Min(uiCount, Size - GetHead()); memcpy(m_Buffer + GetHead(), pSource, uiElementsToWrite * sizeof(T)); AdvanceHead(uiElementsToWrite); return Write(pSource + uiElementsToWrite, uiCount - uiElementsToWrite); } return true; }