Skip to content
Snippets Groups Projects
Commit 9d35d7ea authored by Branson Craig Stephens's avatar Branson Craig Stephens
Browse files

Chris's fix to gstlal_veto_timeseries_to_frames checking for new file logic

parent 78de5768
No related branches found
No related tags found
No related merge requests found
......@@ -71,6 +71,7 @@ class vetoSource:
# get the file list
pathPrefix = os.path.join(inputPath,inputPre)
self.pathPrefix = pathPrefix
self.inputPre = inputPre
self.inputExt = inputExt
filePathList = self.check_for_new_files()
self.fileQueue = deque(filePathList)
......@@ -96,16 +97,26 @@ class vetoSource:
# XXX Set the buffer length. Assume fixed for all files!
self.buffer_len = firstVals.nbytes
def check_for_new_files(self):
def check_for_new_files(self, timestamp=0):
# get the file list
pattern = self.pathPrefix + '*' + self.inputExt
filePathList = glob.glob(pattern)
def is_current_file(path):
filePath = os.path.basename(path)
print "filePath = %s" % filePath
print "pre = %s" % self.pathPrefix
rest = filePath[len(self.inputPre):]
print "rest = %s" % rest
if len(rest)>0:
return int(rest.split('-')[0])>=timestamp
else:
return None
filePathList = filter(is_current_file, glob.glob(pattern))
filePathList.sort()
return filePathList
def need_data(self, src, need_bytes=None):
# Check if new data has arrived on disk.
filePathQueue.extend(self.check_for_new_files())
filePathQueue.extend(self.check_for_new_files(self.next_output_timestamp))
try:
# Get the gpsstart time from the filename.
......@@ -117,16 +128,16 @@ class vetoSource:
duration = int(rest[:rest.find(self.inputExt)])
# Push gap if the current block is ahead of our timestamps.
# FIXME: Give user some wiggle room to wait for the next file?
if gpsstart * gst.SECOND > self.next_output_timestamp:
# FIXME: Give user some wiggle room to wait for the next file?
if gpsstart * gst.SECOND > self.next_output_timestamp:
# Build the buffer.
buf = gst.buffer_new_and_alloc(0)
buf.timestamp = gpsstart * gst.SECOND
gap_duration = self.next_output_timestamp - gpsstart * gst.SECOND
buf.duration = gap_duration
buf.offset = 0
# FIXME: What if the gap_duration != normal duration?
# A: We'll need a next_output_offset as well
# FIXME: What if the gap_duration != normal duration?
# A: We'll need a next_output_offset as well
buf.offset_end = gap_duration * self.rate
buf.flag_set(gst.BUFFER_FLAG_GAP)
self.next_output_timestamp += buf.gap_duration * gst.SECOND
......@@ -260,7 +271,7 @@ elif options.output_type == "shm":
# FIXME: I think this means it needs to be read at least once
lvshmsink.set_property("buffer-mode", 1)
else:
raise ValueError("Invalid output type.")
raise ValueError("Invalid output type.")
#
# process segment
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment