// EMF 5/30/03: never clear cache, just don't write if older than // what's there... public void put(ChannelMap cm) { try { if (debug > 3) System.err.println("BRCache.put: cm " + cm); if (debug > 3) for (int i = 0; i < cm.NumberOfChannels(); i++) { System.err.println(i + ": " + cm.GetTimeStart(i) + " " + cm.GetData(i)); } // check must be on per channel basis ChannelMap cmCache = new ChannelMap(); Double[] lastTimeD = sink.getEndTimes(cm); for (int i = 0; i < cm.NumberOfChannels(); i++) { double thisTime = cm.GetTimeStart(i); if (lastTimeD[i] == null || lastTimeD[i].doubleValue() < thisTime) { int idx = cmCache.Add(cm.GetName(i)); cmCache.PutTimeRef(cm, i); cmCache.PutDataRef(idx, cm, i); } } source.Flush(cmCache); /* //if time goes backwards, reset ring buffer double thisTime=Double.MAX_VALUE; for (int i=0;i<cm.NumberOfChannels();i++) { double time=cm.GetTimeStart(i)+cm.GetTimeDuration(i); if (time<thisTime) thisTime=time; } if (thisTime<lastTime) { //reset ring buffer and clear endTimes if (debug>3) System.err.println("BRCache.put: reset ring buffer"); source.SetRingBuffer(1000,"none",0); endTimes.clear(); } if (thisTime<Double.MAX_VALUE) lastTime=thisTime; //put end times into cache for (int i=0;i<cm.NumberOfChannels();i++) { endTimes.put(cm.GetName(i),new Double(cm.GetTimeStart(i)+cm.GetTimeDuration(i))); } //put data into server source.Flush(cm); */ } catch (Exception e) { System.err.println("BRCache.put exception: " + e.getMessage()); e.printStackTrace(); } }