diff --git a/fus_ds_package/fus_driving_systems/config/create_config.py b/fus_ds_package/fus_driving_systems/config/create_config.py index 75971ea..a87cc5c 100644 --- a/fus_ds_package/fus_driving_systems/config/create_config.py +++ b/fus_ds_package/fus_driving_systems/config/create_config.py @@ -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 diff --git a/fus_ds_package/fus_driving_systems/config/ds_config.ini b/fus_ds_package/fus_driving_systems/config/ds_config.ini index eb4dff6..08adf12 100644 --- a/fus_ds_package/fus_driving_systems/config/ds_config.ini +++ b/fus_ds_package/fus_driving_systems/config/ds_config.ini @@ -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 diff --git a/fus_ds_package/fus_driving_systems/igt/igt_ds.py b/fus_ds_package/fus_driving_systems/igt/igt_ds.py index babc273..5aa8a3f 100644 --- a/fus_ds_package/fus_driving_systems/igt/igt_ds.py +++ b/fus_ds_package/fus_driving_systems/igt/igt_ds.py @@ -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() diff --git a/fus_ds_package/fus_driving_systems/sequence.py b/fus_ds_package/fus_driving_systems/sequence.py index 6c57d67..ee79cee 100644 --- a/fus_ds_package/fus_driving_systems/sequence.py +++ b/fus_ds_package/fus_driving_systems/sequence.py @@ -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): @@ -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'] @@ -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): @@ -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): @@ -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): """ @@ -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): diff --git a/standalone_driving_system_software/standalone_igt.py b/standalone_driving_system_software/standalone_igt.py index 24161cd..504a627 100644 --- a/standalone_driving_system_software/standalone_igt.py +++ b/standalone_driving_system_software/standalone_igt.py @@ -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 @@ -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 @@ -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/