/// <summary>
        /// Must make sure the input tracings are continuous in time e.g. no overlaps or gaps
        /// </summary>
        /// <param name="inData"></param>
        /// <param name="FHRsList"></param>
        /// <param name="UPsList"></param>
        private bool UpdateEndTracingTime(TracingData inData, List <byte> FHRsList, List <byte> UPsList)
        {
            lock (s_mainLockObject)
            {
                String logHeader = "Patterns Add On Manager, Patterns Session Data, Update End Tracing Time";
                int    nTimeDiff = (int)(inData.StartTime - EndTimeOfPreviousTracings).TotalSeconds;
                if (nTimeDiff < 1) // Overlap
                {
                    int toRem = Math.Abs(nTimeDiff) + 1;
                    Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "Overlap (sec): " + toRem.ToString());
                    UPsList.RemoveRange(0, toRem);
                    FHRsList.RemoveRange(0, toRem * 4);
                }
                else if (nTimeDiff > 1) // Gap
                {
                    if (nTimeDiff > MaximumBridgeableGap)
                    {
                        Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "The gap is too long, engine restarting.");
                        return(false);
                    }

                    Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "Gap (sec): " + nTimeDiff.ToString());
                    for (int toAdd = nTimeDiff - 1; toAdd > 0; toAdd--)
                    {
                        UPsList.Insert(0, NoData);
                        FHRsList.InsertRange(0, new byte[] { NoData, NoData, NoData, NoData });
                    }
                }

                EndTimeOfPreviousTracings = EndTimeOfPreviousTracings.AddSeconds(UPsList.Count);
                Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "EndTimeOfPreviousTracings: " + EndTimeOfPreviousTracings.ToString());
                return(true);
            }
        }
        public bool AppendRequest(TracingData inData)
        {
            String logHeader   = "Patterns Add On Manager, Patterns Session Data, Append Request";
            String inDataTrace = "PreviousDetectededEndTime = " + inData.PreviousDetectededEndTime + "\nStartTime = " + inData.StartTime;

            Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, inDataTrace);

            //PAW
            Logger.WriteLogEntry(TraceEventType.Verbose, "Debug PAW:FHR", inData.Fhr);
            Logger.WriteLogEntry(TraceEventType.Verbose, "Debug PAW:UP", inData.Up);


            System.Diagnostics.Trace.WriteLine("AppendRequest reached");
            if (inData.Fhr == null || inData.Up == null)
            {
                Logger.WriteLogEntry(TraceEventType.Error, logHeader, "Either FHR or UP is NULL");
                return(false);
            }

            System.Diagnostics.Trace.WriteLine("AppendRequest: m_GUIDQueue size (before nq) = " + m_GUIDQueue.Count);

            m_GUIDQueue.Enqueue(inData);
            System.Diagnostics.Trace.WriteLine("AppendRequest: m_GUIDQueue size (after nq) = " + m_GUIDQueue.Count);
            Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "GUIDQueue size: " + m_GUIDQueue.Count);
            if (m_GUIDQueue.Count == 1)
            {
                PrepareProcessPatterns();
            }

            return(true);
        }
        private void ReInstance(TracingData inData, int nTracingLength)
        {
            lock (s_mainLockObject)
            {
                UnInitSessionData();
                LastRequest = DateTime.Now;

                // Clear buffers of live calculation
                m_fhrToProcess.Clear();
                m_upToProcess.Clear();

                String logHeader = "Patterns Add On Manager, Patterns Session Data, ReInstance";
                Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "Engine should be null, is " + Engine == null ? "null" : "exists");
                Engine = new PatternsProcessorWrapper(GUID, DateTime.Now);
                Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "Engine should exist, is " + Engine == null ? "null" : "exists");
                System.Diagnostics.Trace.WriteLine("ReInstance: inData.StartTime (before RI)= " + StartTime.ToString());
                StartTime = inData.StartTime;
                EndTimeOfPreviousTracings = inData.StartTime.AddSeconds(nTracingLength);
                System.Diagnostics.Trace.WriteLine("PrepareProcessPatterns: EndTimeOfPreviousTracings (after RI)= " + EndTimeOfPreviousTracings.ToString());
                System.Diagnostics.Trace.WriteLine("PrepareProcessPatterns: inData.StartTime (after RI)= " + StartTime.ToString());
                Logger.WriteLogEntry(TraceEventType.Verbose, logHeader, "Engine recreated");
            }
        }