Coverage for  / opt / hostedtoolcache / Python / 3.11.14 / x64 / lib / python3.11 / site-packages / rattlesnake / components / environments.py: 98%

63 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-27 18:22 +0000

1# -*- coding: utf-8 -*- 

2""" 

3This file contains the interfaces to the individual environments, and should be 

4modified when adding new environment control strategies. 

5 

6Rattlesnake Vibration Control Software 

7Copyright (C) 2021 National Technology & Engineering Solutions of Sandia, LLC 

8(NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. 

9Government retains certain rights in this software. 

10 

11This program is free software: you can redistribute it and/or modify 

12it under the terms of the GNU General Public License as published by 

13the Free Software Foundation, either version 3 of the License, or 

14(at your option) any later version. 

15 

16This program is distributed in the hope that it will be useful, 

17but WITHOUT ANY WARRANTY; without even the implied warranty of 

18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

19GNU General Public License for more details. 

20 

21You should have received a copy of the GNU General Public License 

22along with this program. If not, see <https://www.gnu.org/licenses/>. 

23""" 

24 

25from enum import Enum 

26import sys 

27import os 

28 

29this_path = os.path.split(__file__)[0] 

30 

31# Here is where the code needs to be modified to create a new environment. 

32 

33 

34class ControlTypes(Enum): 

35 """Enumeration of the possible control types""" 

36 

37 COMBINED = 0 

38 RANDOM = 1 

39 TRANSIENT = 2 

40 SINE = 3 

41 TIME = 4 

42 # NONLINEAR = 5 

43 MODAL = 6 

44 # Add new environment types here 

45 

46 

47# Name for each environment 

48environment_long_names = {} 

49environment_long_names[ControlTypes.RANDOM] = "MIMO Random Vibration" 

50environment_long_names[ControlTypes.TRANSIENT] = "MIMO Transient" 

51environment_long_names[ControlTypes.SINE] = "MIMO Sine Vibration" 

52environment_long_names[ControlTypes.TIME] = "Time Signal Generation" 

53# environment_long_names[ControlTypes.NONLINEAR] = 'Nonlinear Normal Modes' 

54environment_long_names[ControlTypes.MODAL] = "Modal Testing" 

55environment_long_names[ControlTypes.COMBINED] = "Combined Environments..." 

56 

57# Add the environment here if it can be used for combined environments 

58combined_environments_capable = [ 

59 ControlTypes.RANDOM, 

60 ControlTypes.TRANSIENT, 

61 ControlTypes.SINE, 

62 ControlTypes.TIME, 

63 ControlTypes.MODAL, 

64] 

65 

66# Define paths to the User Interface UI Files 

67environment_definition_ui_paths = {} 

68environment_prediction_ui_paths = {} 

69environment_run_ui_paths = {} 

70# This is true if running from an executable and the UI is embedded in the executable 

71if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): 

72 directory = sys._MEIPASS # pylint: disable=protected-access 

73else: 

74 directory = this_path 

75 

76# Base Controller UI 

77ui_path = os.path.join(directory, "combined_environments_controller.ui") 

78environment_select_ui_path = os.path.join(directory, "environment_selector.ui") 

79control_select_ui_path = os.path.join(directory, "control_select.ui") 

80# Random Vibration Environment 

81environment_definition_ui_paths[ControlTypes.RANDOM] = os.path.join( 

82 directory, "random_vibration_definition.ui" 

83) 

84environment_prediction_ui_paths[ControlTypes.RANDOM] = os.path.join( 

85 directory, "random_vibration_prediction.ui" 

86) 

87environment_run_ui_paths[ControlTypes.RANDOM] = os.path.join(directory, "random_vibration_run.ui") 

88system_identification_ui_path = os.path.join(directory, "system_identification.ui") 

89transformation_matrices_ui_path = os.path.join(directory, "transformation_matrices.ui") 

90# Time Environment 

91environment_definition_ui_paths[ControlTypes.TIME] = os.path.join(directory, "time_definition.ui") 

92environment_run_ui_paths[ControlTypes.TIME] = os.path.join(directory, "time_run.ui") 

93# Transient Environment 

94environment_definition_ui_paths[ControlTypes.TRANSIENT] = os.path.join( 

95 directory, "transient_definition.ui" 

96) 

97environment_prediction_ui_paths[ControlTypes.TRANSIENT] = os.path.join( 

98 directory, "transient_prediction.ui" 

99) 

100environment_run_ui_paths[ControlTypes.TRANSIENT] = os.path.join(directory, "transient_run.ui") 

101# Sine Environment 

102environment_definition_ui_paths[ControlTypes.SINE] = os.path.join(directory, "sine_definition.ui") 

103environment_prediction_ui_paths[ControlTypes.SINE] = os.path.join(directory, "sine_prediction.ui") 

104environment_run_ui_paths[ControlTypes.SINE] = os.path.join(directory, "sine_run.ui") 

105sine_sweep_table_ui_path = os.path.join(directory, "sine_sweep_table.ui") 

106filter_explorer_ui_path = os.path.join(directory, "sine_filter_explorer.ui") 

107# Modal Environments 

108environment_definition_ui_paths[ControlTypes.MODAL] = os.path.join(directory, "modal_definition.ui") 

109environment_run_ui_paths[ControlTypes.MODAL] = os.path.join(directory, "modal_run.ui") 

110modal_mdi_ui_path = os.path.join(directory, "modal_acquisition_window.ui") 

111 

112# Import the process function and the UI from the module and add them to the 

113# respective dictionaries 

114environment_processes = {} 

115environment_UIs = {} 

116# Random Vibration 

117from .random_vibration_sys_id_environment import ( # noqa # pylint: disable=wrong-import-position 

118 random_vibration_process, 

119 RandomVibrationUI, 

120) 

121 

122environment_processes[ControlTypes.RANDOM] = random_vibration_process 

123environment_UIs[ControlTypes.RANDOM] = RandomVibrationUI 

124# Time Signal Generation 

125from .time_environment import time_process, TimeUI # noqa # pylint: disable=wrong-import-position 

126 

127environment_processes[ControlTypes.TIME] = time_process 

128environment_UIs[ControlTypes.TIME] = TimeUI 

129# Transient 

130from .transient_sys_id_environment import ( # noqa # pylint: disable=wrong-import-position 

131 transient_process, 

132 TransientUI, 

133) 

134 

135environment_processes[ControlTypes.TRANSIENT] = transient_process 

136environment_UIs[ControlTypes.TRANSIENT] = TransientUI 

137# Sine 

138from .sine_sys_id_environment import ( # noqa # pylint: disable=wrong-import-position 

139 sine_process, 

140 SineUI, 

141) 

142 

143environment_processes[ControlTypes.SINE] = sine_process 

144environment_UIs[ControlTypes.SINE] = SineUI 

145# Modal 

146from .modal_environment import ( # noqa # pylint: disable=wrong-import-position 

147 modal_process, 

148 ModalUI, 

149) 

150 

151environment_processes[ControlTypes.MODAL] = modal_process 

152environment_UIs[ControlTypes.MODAL] = ModalUI 

153 

154# End of code needed to be modified to create a new environment