Skip to content

Commit 9420917

Browse files
Alexebrahimebrahim
authored andcommitted
Add parameter in start_sonication() to select external power supply. (#75)
-Change all start_trigger() calls to start_sonication() calls in test scripts
1 parent b202ccd commit 9420917

File tree

9 files changed

+35
-32
lines changed

9 files changed

+35
-32
lines changed

notebooks/test_multiple_modules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
interface.txdevice.demo_tx7332(device_index)
3232

3333
print("Starting Trigger...")
34-
if interface.txdevice.start_trigger():
34+
if interface.start_sonication():
3535
print("Trigger Running Press enter to STOP:")
3636
input() # Wait for the user to press Enter
37-
if interface.txdevice.stop_trigger():
37+
if interface.stop_sonication():
3838
print("Trigger stopped successfully.")
3939
else:
4040
print("Failed to stop trigger.")

notebooks/test_nucleo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
print("Failed to get current trigger setting.")
5656

5757
print("Starting Trigger with current setting...")
58-
if interface.txdevice.start_trigger():
58+
if interface.start_sonication():
5959
print("Trigger Running Press enter to STOP:")
6060
input() # Wait for the user to press Enter
61-
if interface.txdevice.stop_trigger():
61+
if interface.stop_sonication():
6262
print("Trigger stopped successfully.")
6363
else:
6464
print("Failed to stop trigger.")
@@ -84,10 +84,10 @@
8484
print("Failed to set trigger setting.")
8585

8686
print("Starting Trigger with updated setting...")
87-
if interface.txdevice.start_trigger():
87+
if interface.start_sonication():
8888
print("Trigger Running Press enter to STOP:")
8989
input() # Wait for the user to press Enter
90-
if interface.txdevice.stop_trigger():
90+
if interface.stop_sonication():
9191
print("Trigger stopped successfully.")
9292
else:
9393
print("Failed to stop trigger.")

notebooks/test_thermal_stress.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
log_interval = 1 # seconds; you can adjust this variable as needed
4242

4343
frequency_kHz = 400 # Frequency in kHz
44-
voltage = 50.0 # Voltage in Volts
44+
voltage = 10.0 # Voltage in Volts
4545
duration_msec = 5 # Pulse Duration in milliseconds
4646
interval_msec = 100 # Pulse Repetition Interval in milliseconds
4747
num_modules = 1 # Number of modules in the system
@@ -347,7 +347,7 @@ def input_wrapper():
347347
user_input = threading.Thread(target=input_wrapper)
348348

349349
logger.info("Starting Trigger...")
350-
if interface.txdevice.start_trigger():
350+
if interface.start_sonication():
351351
logger.info("Trigger Running...")
352352
logger.info("Press enter to STOP trigger:")
353353

@@ -370,7 +370,7 @@ def input_wrapper():
370370
user_input.join()
371371

372372
time.sleep(0.5) # Give the logging thread time to finish
373-
if interface.txdevice.stop_trigger():
373+
if interface.stop_sonication():
374374
logger.info("Trigger stopped successfully.")
375375
else:
376376
logger.error("Failed to stop trigger.")

notebooks/test_ti_cfg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363
print("Press enter to START trigger:")
6464
input() # Wait for the user to press Enter
6565
print("Starting Trigger...")
66-
if interface.txdevice.start_trigger():
66+
if interface.start_sonication():
6767
print("Trigger Running Press enter to STOP:")
6868
input() # Wait for the user to press Enter
69-
if interface.txdevice.stop_trigger():
69+
if interface.stop_sonication():
7070
print("Trigger stopped successfully.")
7171
else:
7272
print("Failed to stop trigger.")

notebooks/test_transmitter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
print("Press enter to START trigger:")
6262
input() # Wait for the user to press Enter
6363
print("Starting Trigger...")
64-
if interface.txdevice.start_trigger():
64+
if interface.start_sonication():
6565
print("Trigger Running Press enter to STOP:")
6666
input() # Wait for the user to press Enter
67-
if interface.txdevice.stop_trigger():
67+
if interface.stop_sonication():
6868
print("Trigger stopped successfully.")
6969
else:
7070
print("Failed to stop trigger.")

notebooks/test_transmitter2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@
9494
print("Failed to get trigger setting.")
9595

9696
print("Starting Trigger...")
97-
if interface.txdevice.start_trigger():
97+
if interface.start_sonication():
9898
print("Trigger Running Press enter to STOP:")
9999
input() # Wait for the user to press Enter
100-
if interface.txdevice.stop_trigger():
100+
if interface.stop_sonication():
101101
print("Trigger stopped successfully.")
102102
else:
103103
print("Failed to stop trigger.")

notebooks/test_updated_if.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,17 @@
151151
else:
152152
print("Failed to get trigger setting.")
153153

154-
155-
156-
print("Turn HV ON")
157-
interface.hvcontroller.turn_hv_on()
158-
159154
print("Starting Trigger...")
160-
if interface.txdevice.start_trigger():
155+
if interface.start_sonication():
161156
print("Trigger Running Press enter to STOP:")
162157
input() # Wait for the user to press Enter
163-
if interface.txdevice.stop_trigger():
158+
if interface.stop_sonication():
164159
print("Trigger stopped successfully.")
165160
else:
166161
print("Failed to stop trigger.")
167162
else:
168163
print("Failed to get trigger setting.")
169164

170-
print("Turn HV OFF")
171-
interface.hvcontroller.turn_hv_off()
172-
173165
print("Reset Device:")
174166
# Ask the user for confirmation
175167
user_input = input("Do you want to reset the device? (y/n): ").strip().lower()

notebooks/test_watertank.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def input_wrapper():
385385
user_input = threading.Thread(target=input_wrapper)
386386

387387
logger.info("Starting Trigger...")
388-
if interface.txdevice.start_trigger():
388+
if interface.start_sonication(use_external_power_supply):
389389
logger.info("Trigger Running...")
390390
logger.info("Press enter to STOP trigger:")
391391

@@ -408,7 +408,7 @@ def input_wrapper():
408408
user_input.join()
409409

410410
time.sleep(0.5) # Give the logging thread time to finish
411-
if interface.txdevice.stop_trigger():
411+
if interface.stop_sonication(use_external_power_supply):
412412
logger.info("Trigger stopped successfully.")
413413
else:
414414
logger.error("Failed to stop trigger.")

src/openlifu/io/LIFUInterface.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def set_solution(self,
282282

283283
logger.info("%s loaded successfully.", solution_name)
284284

285-
def start_sonication(self) -> bool:
285+
def start_sonication(self, use_external_power_supply:bool=False) -> bool:
286286
"""
287287
Start sonication.
288288
@@ -292,8 +292,12 @@ def start_sonication(self) -> bool:
292292
if self._test_mode:
293293
return True
294294

295-
logger.info("Turn ON HV")
296-
bHvOn = self.hvcontroller.turn_hv_on()
295+
if not use_external_power_supply:
296+
logger.info("Turn ON HV")
297+
bHvOn = self.hvcontroller.turn_hv_on()
298+
else:
299+
logger.info("Using external power supply, HV will not be turned ON.")
300+
bHvOn = True
297301

298302
if self._async_mode:
299303
self.txdevice.async_mode(True)
@@ -340,7 +344,7 @@ def get_status(self) -> LIFUInterfaceStatus:
340344

341345
return self.status
342346

343-
def stop_sonication(self) -> bool:
347+
def stop_sonication(self, use_external_power_supply:bool=False) -> bool:
344348
"""
345349
Stop sonication.
346350
@@ -353,7 +357,14 @@ def stop_sonication(self) -> bool:
353357
logger.info("Stop Sonication")
354358
# Send the solution data to the device
355359
bTriggerOff = self.txdevice.stop_trigger()
356-
bHvOff = self.hvcontroller.turn_hv_off()
360+
361+
if not use_external_power_supply:
362+
logger.info("Turn OFF HV")
363+
bHvOff = self.hvcontroller.turn_hv_off()
364+
else:
365+
logger.info("Using external power supply, HV will not be turned OFF.")
366+
bHvOff = True
367+
357368
if self._async_mode:
358369
self.txdevice.async_mode(False)
359370

0 commit comments

Comments
 (0)