Skip to content

Commit

Permalink
#35, #36. #37 & #38
Browse files Browse the repository at this point in the history
  • Loading branch information
MaCuinea committed Dec 3, 2024
1 parent 0861310 commit ab5e8eb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fus_ds_package/fus_driving_systems/config/create_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

config['General']['Temporary logging path'] = 'C:\\Temp'

MAX_ALLOWED_PRESSURE = 1.2 # MPa
MAX_ALLOWED_PRESSURE = 1.4 # MPa
config['General']['Maximum pressure allowed in free water [MPa]'] = str(MAX_ALLOWED_PRESSURE)

# if ramp shapes are changed, don't forget to change values used in code as well
Expand Down
2 changes: 1 addition & 1 deletion fus_ds_package/fus_driving_systems/config/ds_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
logger name = driving_system
configuration file folder = config
temporary logging path = C:\Temp
maximum pressure allowed in free water [mpa] = 1.2
maximum pressure allowed in free water [mpa] = 1.4
ramp shapes = Rectangular - no ramping
Linear
Tukey
Expand Down
4 changes: 4 additions & 0 deletions fus_ds_package/fus_driving_systems/igt/igt_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ def send_sequence(self, seq1, seq2=None):
# Apply ramping
if seq1.pulse_ramp_shape != config['General']['Ramp shape.rect']:
self._apply_ramping(seq1)
else:
self.gen.setPulseModulation([], 0, [], 0) # disable any modulation
self.gen.setPulseRamp(unifus.PulseRamp.Rising, 0)
self.gen.setPulseRamp(unifus.PulseRamp.Falling, 0)

# (optional) restore disabled channels
self.gen.enableAllChannels()
Expand Down
42 changes: 31 additions & 11 deletions fus_ds_package/fus_driving_systems/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,10 @@ def global_power(self, global_power):
else:
# Chosen system is not SC.
if global_power > 0:
logger.warning('Global power parameter is not available for ' +
'chosen driving system. Use ampl [%], press ' +
'[MPa] or volt [V] instead.')
logger.error('Global power parameter is not available for ' +
'chosen driving system. Use ampl [%], press ' +
'[MPa] or volt [V] instead.')
sys.exit()

@property
def press(self):
Expand Down Expand Up @@ -665,6 +666,13 @@ def press(self, press):
is_validated = validate_value(press, 'Maximum pressure in free water [MPa] (press)',
True, True, False, False)
if is_validated:
max_press = float(config['General']['Maximum pressure allowed in free water [MPa]'])
if press > max_press:
logger.error(f'The set maximum pressure in free water of {press} [MPa] is ' +
f'crossing the allowed limit of {max_press} [MPa]. Please change' +
' your value.')
sys.exit()

self._press = press

self._chosen_power = config['General']['Power option.press']
Expand All @@ -679,8 +687,9 @@ def press(self, press):
f' results in a voltage of {self._volt:.2f} [V] and an amplitude ' +
f'of {self._ampl:.2f} [%].')
else:
logger.warning('No pressure compensation parameters available in the configuration' +
' file for chosen equipment combination. Enter amplitude [%].')
logger.error('No pressure compensation parameters available in the configuration' +
' file for chosen equipment combination. Enter amplitude [%].')
sys.exit()

@property
def volt(self):
Expand Down Expand Up @@ -725,8 +734,9 @@ def volt(self, volt):
f' pressure in free water of {self._press:.2f} [MPa] and an amplitude' +
f' of {self._ampl:.2f} [%].')
else:
logger.warning('No pressure compensation parameters available in the configuration' +
' file for chosen equipment combination. Enter amplitude [%].')
logger.error('No pressure compensation parameters available in the configuration' +
' file for chosen equipment combination. Enter amplitude [%].')
sys.exit()

@property
def ampl(self):
Expand Down Expand Up @@ -779,9 +789,10 @@ def ampl(self, ampl):
else:
# Chosen system is not IGT.
if ampl > 0:
logger.warning('Amplitude parameter is not available for ' +
'chosen driving system. Use global_power [mW]' +
' instead.')
logger.error('Amplitude parameter is not available for ' +
'chosen driving system. Use global_power [mW]' +
' instead.')
sys.exit()

def get_focus_options(self):
"""
Expand Down Expand Up @@ -1629,7 +1640,16 @@ def _calc_press(self):
"""

press_pa = (self._ampl - self.P2A_b) / (self.P2A_a * self._eq_factor)
self._press = press_pa * 1e-6 # convert to MPa
press_mpa = press_pa * 1e-6 # convert to MPa

max_press = float(config['General']['Maximum pressure allowed in free water [MPa]'])
if press_mpa > max_press:
logger.error(f'The set maximum pressure in free water of {press_mpa} [MPa] is ' +
f'crossing the allowed limit of {max_press} [MPa]. Please change' +
' your value.')
sys.exit()

self._press = press_mpa # convert to MPa


def validate_value(value, input_param, check_num, check_pos, check_nonzero, check_bool):
Expand Down
20 changes: 20 additions & 0 deletions standalone_driving_system_software/standalone_igt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
# import the 'fus_driving_systems - sequence' into your code
##############################################################################

import sys

from fus_driving_systems import driving_system, transducer
from fus_driving_systems import sequence

Expand Down Expand Up @@ -84,6 +86,16 @@
# choose one transducer from that list as input
seq2.transducer = 'IS_PCD15287_01002'

# Check if available channels is equal to the number of elements of the transducers combined
n_comb_elem = seq1.transducer.elements + seq2.transducer.elements
if seq1.driving_sys.available_ch != n_comb_elem:
logger.error(f'Number of available channels ({seq1.driving_sys.available_ch}) is not ' +
f'equal to the number of elements of the transducers combined ({n_comb_elem}' +
f'). Equipment configuration {seq1.driving_sys.name} - ' +
f'{seq1.transducer.name} & {seq2.transducer.name} does ' +
'not seem to be compatible or use_two_transducers is incorrectly True.')
sys.exit()

# set general parameters
seq2.oper_freq = 300 # [kHz], operating frequency
seq2.focus_wrt_exit_plane = 80 # [mm], focal depth w.r.t. the exit plane and FWHM middle
Expand All @@ -100,6 +112,14 @@
# seq2.volt = 0 # [V], voltage per channel
# seq2.ampl = 10 # [%], amplitude. NOTE: DIFFERENT THAN SC

# Check if available channels is equal to the number of elements of the transducer
elif seq1.driving_sys.available_ch != seq1.transducer.elements:
logger.error(f'Number of available channels ({seq1.driving_sys.available_ch}) is not equal to' +
f' the number of elements of the transducer ({seq1.transducer.elements}). ' +
f'Equipment configuration {seq1.driving_sys.name} - {seq1.transducer.name} does ' +
'not seem to be compatible or use_two_transducers is incorrectly False.')
sys.exit()

# # timing parameters # #
# you can use the TUS Calculator to visualize the timing parameters:
# https://www.socsci.ru.nl/fusinitiative/tuscalculator/
Expand Down

0 comments on commit ab5e8eb

Please sign in to comment.