From cf65c86187070c262c8df01ed505a12da0983e15 Mon Sep 17 00:00:00 2001
From: Aaron Viets <aaron.viets@ligo.org>
Date: Tue, 6 Aug 2019 15:04:04 -0500
Subject: [PATCH] gstlal_compute_strain:  Option to use timer in lal_insertgap
 to prevent pipeline from falling behind real time when running in low
 latency.

---
 gstlal-calibration/bin/gstlal_compute_strain   | 3 ++-
 gstlal-calibration/python/calibration_parts.py | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gstlal-calibration/bin/gstlal_compute_strain b/gstlal-calibration/bin/gstlal_compute_strain
index d57f259316..3b019b4fb8 100755
--- a/gstlal-calibration/bin/gstlal_compute_strain
+++ b/gstlal-calibration/bin/gstlal_compute_strain
@@ -269,6 +269,7 @@ compute_calib_factors_complex_caps = "audio/x-raw, format=Z128LE, rate=%d, chann
 
 # Short cut names for a few other items that appear numerous times
 input_frame_duration = int(InputConfigs["inputframeduration"])
+wait_time = float(InputConfigs["waittime"]) if ("waittime" in InputConfigs and InputConfigs["datasource"] == "lvshm") else 0.0
 filter_latency_factor = float(PipelineConfigs["filterlatency"])
 demodulation_filter_time = int(TDCFConfigs["demodulationfiltertime"])
 coherence_unc_threshold = float(TDCFConfigs["coherenceuncthreshold"])
@@ -1140,7 +1141,7 @@ if DebuggingConfigs["pipelinegraphfilename"] != "None":
 
 # Get everything hooked up and fill in discontinuities
 for key, chan in zip(headkeys, channel_list):
-	head_dict[key] = calibration_parts.hook_up(pipeline, demux, chan[1], instrument, float(PipelineConfigs["bufferlength"]))
+	head_dict[key] = calibration_parts.hook_up(pipeline, demux, chan[1], instrument, float(PipelineConfigs["bufferlength"]), wait_time = wait_time)
 
 # The DARM_ERR channel follows different paths if we're doing full vs. partial calibration
 if CalibrationConfigs["calibrationmode"] == "Full":
diff --git a/gstlal-calibration/python/calibration_parts.py b/gstlal-calibration/python/calibration_parts.py
index 687e30d495..a49914db07 100644
--- a/gstlal-calibration/python/calibration_parts.py
+++ b/gstlal-calibration/python/calibration_parts.py
@@ -222,11 +222,11 @@ def write_graph(demux, pipeline, name):
 # Common element combo functions
 #
 
-def hook_up(pipeline, demux, channel_name, instrument, buffer_length, element_name_suffix = ""):
+def hook_up(pipeline, demux, channel_name, instrument, buffer_length, element_name_suffix = "", wait_time = 0):
 	if channel_name.endswith("UNCERTAINTY"):
-		head = mkinsertgap(pipeline, None, bad_data_intervals = [-1e35, -1e-35, 1e-35, 1e35], insert_gap = False, remove_gap = True, fill_discont = True, block_duration = int(1000000000 * buffer_length), replace_value = 1, name = "insertgap_%s%s" % (channel_name, element_name_suffix))
+		head = mkinsertgap(pipeline, None, bad_data_intervals = [-1e35, -1e-35, 1e-35, 1e35], insert_gap = False, remove_gap = True, fill_discont = True, block_duration = int(1000000000 * buffer_length), replace_value = 1, name = "insertgap_%s%s" % (channel_name, element_name_suffix), wait_time = int(1000000000 * wait_time))
 	else:
-		head = mkinsertgap(pipeline, None, bad_data_intervals = [-1e35, -1e-35, 1e-35, 1e35], insert_gap = False, remove_gap = True, fill_discont = True, block_duration = int(1000000000 * buffer_length), replace_value = 0, name = "insertgap_%s%s" % (channel_name, element_name_suffix))
+		head = mkinsertgap(pipeline, None, bad_data_intervals = [-1e35, -1e-35, 1e-35, 1e35], insert_gap = False, remove_gap = True, fill_discont = True, block_duration = int(1000000000 * buffer_length), replace_value = 0, name = "insertgap_%s%s" % (channel_name, element_name_suffix), wait_time = int(1000000000 * wait_time))
 	pipeparts.src_deferred_link(demux, "%s:%s" % (instrument, channel_name), head.get_static_pad("sink"))
 
 	return head
-- 
GitLab