From 4391dc39d5ecf1ba6599dfd22d0f8e7e82b56fd8 Mon Sep 17 00:00:00 2001
From: Runner PC Cavity Lab <johannes.schabbauer@tuwien.ac.at>
Date: Thu, 28 Nov 2024 13:53:10 +0100
Subject: [PATCH] Bugfix in AWG worker (when no output is defined)

---
 SpectrumAWG/blacs_workers.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/SpectrumAWG/blacs_workers.py b/SpectrumAWG/blacs_workers.py
index 2dc0b8c..9be404a 100644
--- a/SpectrumAWG/blacs_workers.py
+++ b/SpectrumAWG/blacs_workers.py
@@ -60,6 +60,7 @@ class SpectrumAWGWorker(Worker):
 
     def transition_to_buffered(self, device_name, h5_file, initial_values, fresh):
         self.AWG.card_stop() # If card was still running, e.g. from manual mode
+        write_setup_and_start = False
         with h5py.File(h5_file,'r') as f:
             group = f[f"devices/{device_name}"]
             for ch in self.channels:
@@ -71,6 +72,7 @@ class SpectrumAWGWorker(Worker):
                 last_index = len(group[ch].attrs)-1
                 for index in range(len(group[ch].attrs)):
                     index_h5 = str(index) # The index in the h5 file is a str
+                    write_setup_and_start = True
                     ### LOOP TROUGH STREAMING STEPS ###
                     instruction = group[ch].attrs[index_h5]
                     instruction_hash = hash(instruction.tobytes())
@@ -109,9 +111,11 @@ class SpectrumAWGWorker(Worker):
                 # FOR IMPLEMENTATION ONE HASE TO INTERWEAVE THE DATA FOR BOTH CHANNELS
                 break 
 
-        self.AWG.card_write_setup() # TODO: Do we have to call that every shot or just once after the initialization?
-        self.AWG.card_start()
-        self.AWG.card_enable_trigger()
+        # If there were no sequences defined in the shot, don't start the AWG
+        if write_setup_and_start:
+            self.AWG.card_write_setup() # TODO: Do we have to call that every shot or just once after the initialization?
+            self.AWG.card_start()
+            self.AWG.card_enable_trigger()
         return initial_values
 
     def transition_to_manual(self):
-- 
GitLab