def __init__(self, scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder( etched_border, "Init, Start, Stop Statistic Measurements") self.setBorder(titled_border) #----- buttons panel buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT, 10, 3)) init_meter_button = JButton("Initialize Meter") init_meter_button.addActionListener( Init_Meter_Button_Listener(self.scl_long_tuneup_controller)) start_statistics_button = JButton("Start Statistic") start_statistics_button.addActionListener( Start_Statistics_Button_Listener(self.scl_long_tuneup_controller)) stop_statistics_button = JButton("Stop") stop_statistics_button.addActionListener( Stop_Statistics_Button_Listener(self.scl_long_tuneup_controller)) counter_lbl = JLabel(" Counter=", JLabel.RIGHT) self.counter_text = DoubleInputTextField(0., ScientificNumberFormat(1), 4) buffer_size_lbl = JLabel(" Buffer Size=", JLabel.RIGHT) self.buffer_size_text = DoubleInputTextField(10., ScientificNumberFormat(1), 4) self.fixInitEenergy_RadioButton = JRadioButton( "Keep Guess Energy (to get offsets)") self.fixInitEenergy_RadioButton.setSelected(false) buttons_panel.add(init_meter_button) buttons_panel.add(start_statistics_button) buttons_panel.add(stop_statistics_button) buttons_panel.add(counter_lbl) buttons_panel.add(self.counter_text) buttons_panel.add(self.fixInitEenergy_RadioButton) buttons_panel.add(buffer_size_lbl) buttons_panel.add(self.buffer_size_text) #----- energy panel energy_panel = JPanel(FlowLayout(FlowLayout.LEFT, 10, 3)) energy_guess_lbl = JLabel( "<html>Initial Guess E<SUB>kin</SUB>[MeV]=<html>", JLabel.RIGHT) self.energy_guess_text = DoubleInputTextField( 0., ScientificNumberFormat(7), 12) energy_lbl = JLabel("<html>Found E<SUB>kin</SUB>[MeV]=<html>", JLabel.RIGHT) self.energy_text = DoubleInputTextField(0., ScientificNumberFormat(7), 12) energy_err_lbl = JLabel("+-", JLabel.RIGHT) self.energy_err_text = DoubleInputTextField(0., ScientificNumberFormat(7), 12) energy_panel.add(energy_guess_lbl) energy_panel.add(self.energy_guess_text) energy_panel.add(energy_lbl) energy_panel.add(self.energy_text) energy_panel.add(energy_err_lbl) energy_panel.add(self.energy_err_text) #----- main panel self.add(buttons_panel, BorderLayout.NORTH) self.add(energy_panel, BorderLayout.CENTER)
def __init__(self, rf_power_controller): self.rf_power_controller = rf_power_controller self.setLayout(GridLayout(3, 1, 1, 1)) self.setBorder(BorderFactory.createEtchedBorder()) start_button = JButton("Start Averaging") start_button.addActionListener( Start_Button_Listener(self.rf_power_controller)) stop_button = JButton("Stop") stop_button.addActionListener( Stop_Button_Listener(self.rf_power_controller)) n_avg_label = JLabel("N Avg.=", JLabel.RIGHT) self.n_avg_text = DoubleInputTextField(10.0, DecimalFormat("###.#"), 5) time_step_label = JLabel("Time Step[sec]=", JLabel.RIGHT) self.time_step_text = DoubleInputTextField(1.1, DecimalFormat("##.#"), 4) send_amp_phase_to_EPICS_button = JButton( "Send New Amp to Selected Cavs") send_amp_phase_to_EPICS_button.addActionListener( Send_Amp_Phase_to_EPICS_Button_Listener(self.rf_power_controller)) make_new_pwrs_as_target_button = JButton( "Make Measured Powers as New Traget for Selected Cavs") make_new_pwrs_as_target_button.addActionListener( Make_New_Pwrs_as_Target_Button_Listener(self.rf_power_controller)) self.status_text = JTextField(30) self.status_text.setForeground(Color.red) self.status_text.setText("Not running.") status_text_label = JLabel("Averaging status:", JLabel.RIGHT) status_panel = JPanel(BorderLayout()) status_panel.add(status_text_label, BorderLayout.WEST) status_panel.add(self.status_text, BorderLayout.CENTER) status_panel.setBorder(BorderFactory.createEtchedBorder()) buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT, 3, 1)) buttons_panel.add(start_button) buttons_panel.add(stop_button) buttons_panel.add(n_avg_label) buttons_panel.add(self.n_avg_text) buttons_panel.add(time_step_label) buttons_panel.add(self.time_step_text) #--------------------------------------- bottom_buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) bottom_buttons_panel_tmp = JPanel(GridLayout(2, 1, 1, 1)) bottom_buttons_panel_tmp0 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) bottom_buttons_panel_tmp1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) bottom_buttons_panel_tmp.add(bottom_buttons_panel_tmp0) bottom_buttons_panel_tmp.add(bottom_buttons_panel_tmp1) bottom_buttons_panel.add(bottom_buttons_panel_tmp) bottom_buttons_panel_tmp0.add(send_amp_phase_to_EPICS_button) bottom_buttons_panel_tmp1.add(make_new_pwrs_as_target_button) #--------------------------------------- self.add(buttons_panel) self.add(status_panel) self.add(bottom_buttons_panel)
def __init__(self,mebt_main_orbit_diff_cntrl,index): self.mebt_main_orbit_diff_cntrl = mebt_main_orbit_diff_cntrl self.setLayout(FlowLayout(FlowLayout.LEFT,3,3)) label = JLabel("Orbit #"+str(index)+" ",JLabel.LEFT) self.dc_label = JLabel("Dipole Corr.: none ",JLabel.RIGHT) field_label = JLabel(" field[T]=",JLabel.RIGHT) self.dc_field_txt = DoubleInputTextField(0.0,ScientificNumberFormat(6),10) percent_label = JLabel(" % of Max Field=",JLabel.RIGHT) self.percent_txt = DoubleInputTextField(90.0,ScientificNumberFormat(1),5) self.add(label) self.add(self.dc_label) self.add(field_label) self.add(self.dc_field_txt) self.add(percent_label) self.add(self.percent_txt)
def __init__(self,mebt_main_orbit_diff_cntrl): self.mebt_main_orbit_diff_cntrl = mebt_main_orbit_diff_cntrl self.setLayout(GridLayout(4,1,3,3)) self.orbit_index_info_panel_0 = Orbit_Index_Info_Panel(self.mebt_main_orbit_diff_cntrl,0) self.orbit_index_info_panel_1 = Orbit_Index_Info_Panel(self.mebt_main_orbit_diff_cntrl,1) self.avg_label = JLabel("Number of Avg.=",JLabel.RIGHT) self.avg_number_txt = DoubleInputTextField(1.0,ScientificNumberFormat(1),5) self.time_step_label = JLabel(" Time step[sec]=",JLabel.RIGHT) self.time_step_txt = DoubleInputTextField(2.0,ScientificNumberFormat(3),5) start_measuring_button = JButton("Start Measuring") start_measuring_button.addActionListener(Start_Measuring_Button_Listener(self.mebt_main_orbit_diff_cntrl)) stop_measuring_button = JButton("Stop") stop_measuring_button.addActionListener(Stop_Measuring_Button_Listener(self.mebt_main_orbit_diff_cntrl)) recalculate_model_button = JButton("Recalculate Model") recalculate_model_button.addActionListener(Recalculate_Model_Button_Listener(self.mebt_main_orbit_diff_cntrl)) status_label = JLabel("Measuring Status:",JLabel.RIGHT) self.status_txt = JTextField(25) self.status_txt.setText("Not running.") self.status_txt.setForeground(Color.red) #------------------------------------------ tmp_panel_1 = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) tmp_panel_1.add(self.orbit_index_info_panel_0) tmp_panel_2 = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) tmp_panel_2.add(self.orbit_index_info_panel_1) tmp_panel_3 = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) tmp_panel_3.add(self.avg_label) tmp_panel_3.add(self.avg_number_txt) tmp_panel_3.add(self.time_step_label) tmp_panel_3.add(self.time_step_txt) tmp_panel_3.add(start_measuring_button) tmp_panel_3.add(stop_measuring_button) tmp_panel_3.add(recalculate_model_button) tmp_panel_4 = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) tmp_panel_4.add(status_label) tmp_panel_4.add(self.status_txt) self.add(tmp_panel_1) self.add(tmp_panel_2) self.add(tmp_panel_3) self.add(tmp_panel_4)
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(FlowLayout(FlowLayout.LEFT,3,3)) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder(etched_border,"BPM00a/b Phase Shift Measurements") self.setBorder(titled_border) #---- measurement stopper self.measure_stopper = Measure_Stopper() #--- buttons------------ start_measurement_button = JButton("Start") start_measurement_button.addActionListener(Start_BPMs_Shift_Measurements_Listener(self.scl_long_tuneup_controller)) stop_measurement_button = JButton("Stop") stop_measurement_button.addActionListener(Stop_BPMs_Shift_Measurements_Listener(self.scl_long_tuneup_controller)) iter_measurement_lbl = JLabel("Iteration=",JLabel.RIGHT) self.iter_measuremen_text = DoubleInputTextField(10.,DecimalFormat("###"),4) bpm_names_lbl = JLabel(" Phases BPM00a/b ",JLabel.RIGHT) old_phases_lbl = JLabel("Old=",JLabel.RIGHT) self.old_phases_text = JTextField(12) new_phases_lbl = JLabel(" New=",JLabel.RIGHT) self.new_phases_text = JTextField(12) phase_shift_lbl = JLabel(" Phase Shift[deg]=",JLabel.RIGHT) self.phase_shift_text = DoubleInputTextField(0.,DecimalFormat("###.##"),6) #---- buttons panel buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) buttons_panel.add(start_measurement_button) buttons_panel.add(stop_measurement_button) buttons_panel.add(iter_measurement_lbl) buttons_panel.add(self.iter_measuremen_text) buttons_panel.add(bpm_names_lbl) buttons_panel.add(old_phases_lbl) buttons_panel.add(self.old_phases_text) buttons_panel.add(new_phases_lbl) buttons_panel.add(self.new_phases_text) buttons_panel.add(phase_shift_lbl) buttons_panel.add(self.phase_shift_text) #---- add to the main subpanel self.add(buttons_panel)
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(FlowLayout(FlowLayout.LEFT,3,3)) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder(etched_border,"BPMs Phase Offsets: start from CCL4 forward") self.setBorder(titled_border) #--- buttons get_offsets_ccl1_button = JButton("Calculate Offsets from CCL4 forward") get_offsets_ccl1_button.addActionListener(Offsets_from_CCL4_Button_Listener(self.scl_long_tuneup_controller)) ccl4_energy_lbl = JLabel("<html> SCL Entrance E<SUB>kin</SUB>[MeV] = <html>",JLabel.RIGHT) self.ccl4_energy_text = DoubleInputTextField(185.6,DecimalFormat("###.###"),6) self.add(get_offsets_ccl1_button) self.add(ccl4_energy_lbl) self.add(self.ccl4_energy_text)
def __init__(self,rfq_keeper_controller): self.rfq_keeper_controller = rfq_keeper_controller self.setLayout(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() self.setBorder(etched_border) buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) #--------------------------------------------- init_keeper_button = JButton("Initialize Keeper") init_keeper_button.addActionListener(Init_Keeper_Button_Listener(self.rfq_keeper_controller)) #--------------------------------------------- buttons_panel.add(init_keeper_button) #--------------------------------------------- info_panel = JPanel(GridLayout(6,2)) label_current_integral = JLabel("Current Integral [nC]=",JLabel.RIGHT) label_reprate = JLabel("Rep. rate[Hz]=",JLabel.RIGHT) label_rfq_pw = JLabel("RFQ Pulse Width=",JLabel.RIGHT) label_target_pwr =JLabel("Avg. Pwr. on Target[kW]=",JLabel.RIGHT) label_rfq_max_pw_correction = JLabel("Max PW Correction=",JLabel.RIGHT) label_update_time = JLabel("Update Time [sec]=",JLabel.RIGHT) #------- self.current_integral_text = DoubleInputTextField("G12.5") self.reprate_text = DoubleInputTextField("F4.1") self.rfq_pw_text = DoubleInputTextField("F6.1") self.target_pwr_text = DoubleInputTextField("F9.3") self.rfq_max_pw_correction_text = DoubleInputTextField("F6.1") self.update_time_text = DoubleInputTextField("F6.1") #------- self.current_integral_text.setHorizontalAlignment(JTextField.CENTER) self.reprate_text.setHorizontalAlignment(JTextField.CENTER) self.rfq_pw_text.setHorizontalAlignment(JTextField.CENTER) self.target_pwr_text.setHorizontalAlignment(JTextField.CENTER) self.rfq_max_pw_correction_text.setHorizontalAlignment(JTextField.CENTER) self.update_time_text.setHorizontalAlignment(JTextField.CENTER) #------- self.rfq_max_pw_correction_text.setValue(20.) self.update_time_text .setValue(1.0) #------- info_panel.add(label_current_integral) info_panel.add(self.current_integral_text) info_panel.add(label_reprate) info_panel.add(self.reprate_text) info_panel.add(label_rfq_pw) info_panel.add(self.rfq_pw_text) info_panel.add(label_target_pwr) info_panel.add(self.target_pwr_text) info_panel.add(label_rfq_max_pw_correction) info_panel.add(self.rfq_max_pw_correction_text) info_panel.add(label_update_time) info_panel.add(self.update_time_text) #---------------------------------------------- inner_0_panel = JPanel(BorderLayout()) inner_0_panel.add(buttons_panel,BorderLayout.NORTH) inner_0_panel.add(info_panel,BorderLayout.CENTER) self.add(inner_0_panel,BorderLayout.NORTH)
def __init__(self,main_loop_controller,cav_wrapper): self.main_loop_controller = main_loop_controller self.cav_wrapper = cav_wrapper self.main_panel = JPanel(BorderLayout()) self.parameters_panel = JPanel(BorderLayout()) #---- backward cavity amplitude move params panel0 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) cav_amp_backward_steps_mult_label = JLabel("N cav. amp. backward steps multiplier =",JLabel.RIGHT) self.cav_amp_backward_steps_mult_text = DoubleInputTextField(1.0,ScientificNumberFormat(2),5) panel0.add(cav_amp_backward_steps_mult_label) panel0.add(self.cav_amp_backward_steps_mult_text) #---- cavity's wait time multiplier panel1 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) cav_amp_wait_time_mult_label = JLabel("Cav. amp. time wait multiplier =",JLabel.RIGHT) self.cav_amp_wait_time_mult_text = DoubleInputTextField(3.0,ScientificNumberFormat(2),5) panel1.add(cav_amp_wait_time_mult_label) panel1.add(self.cav_amp_wait_time_mult_text) #---- cavity's safe amplitude up and down limits panel2 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) safe_relative_amp_up_label = JLabel("Cav. amp. safe Up [%]=",JLabel.RIGHT) self.safe_relative_amp_up_text = DoubleInputTextField(7.0,ScientificNumberFormat(2),5) panel2.add(safe_relative_amp_up_label) panel2.add(self.safe_relative_amp_up_text) panel3 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) safe_relative_amp_down_label = JLabel("Cav. amp. safe Down [%]=",JLabel.RIGHT) self.safe_relative_amp_down_text = DoubleInputTextField(7.0,ScientificNumberFormat(2),5) panel3.add(safe_relative_amp_down_label) panel3.add(self.safe_relative_amp_down_text) #----- cavity's guess phase[deg] and amplitude[%] corrections after 360 deg full scan for inner BPMs panel4 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) guess_phase_shift_label = JLabel("Cav. Guess Phase Shift after Full Scan [deg]=",JLabel.RIGHT) self.guess_phase_shift_text = DoubleInputTextField(0.0,ScientificNumberFormat(2),5) panel4.add(guess_phase_shift_label) panel4.add(self.guess_phase_shift_text) panel5 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) guess_cav_amp_shift_label = JLabel("Cav. Amp Shift after Full Scan [%]=",JLabel.RIGHT) self.guess_cav_amp_shift_text = DoubleInputTextField(0.0,ScientificNumberFormat(2),5) panel5.add(guess_cav_amp_shift_label) panel5.add(self.guess_cav_amp_shift_text) #----------------------------------------------- params_panel = JPanel(GridLayout(6,1,1,1)) params_panel.add(panel0) params_panel.add(panel1) params_panel.add(panel2) params_panel.add(panel3) params_panel.add(panel4) params_panel.add(panel5) #------------------------------------------------ self.parameters_panel.add(params_panel,BorderLayout.NORTH) #------------------------------------------------ self.scan_progress_bar = Scan_Progress_Bar(self.main_loop_controller,self) #------------------------------------------------ cav_wrapper.safe_relative_amp_up_text = self.safe_relative_amp_up_text cav_wrapper.safe_relative_amp_down_text = self.safe_relative_amp_down_text
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder(etched_border,"SetUp Cavities' New Design Amplitudes and Phases") self.setBorder(titled_border) #--- buttons------------ init_model_button = JButton("Init SCL Model") init_model_button.addActionListener(Init_Tracking_Model_Listener(self.scl_long_tuneup_controller)) read_epics_button = JButton("<html>Get New Live A<SUB>EPICS</SUB><html>") read_epics_button.addActionListener(Read_From_EPICS_Listener(self.scl_long_tuneup_controller)) copy_old_button = JButton("Restore Synch. Phases") copy_old_button.addActionListener(Copy_Old_to_New_Listener(self.scl_long_tuneup_controller)) change_selected_lbl = JLabel("<html>Change Selected New Δφ<SUB>Synch</SUB>(deg)<html>",JLabel.RIGHT) self.avg_gap_phase_wheel = Wheelswitch() self.avg_gap_phase_wheel.setFormat("+###.#") self.avg_gap_phase_wheel.setValue(0.) self.avg_gap_phase_wheel.addPropertyChangeListener("value", Wheel_Listener(self.scl_long_tuneup_controller)) self.is_wheel_listen = true #---- buttons panel buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) buttons_panel.add(init_model_button) buttons_panel.add(read_epics_button) buttons_panel.add(copy_old_button) #---- wheel panle wheel_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) wheel_panel.add(change_selected_lbl) wheel_panel.add(self.avg_gap_phase_wheel) #---- the energy panel energy_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) energy_calc_button = JButton("<html>Calculate E<SUB>kin</SUB><html>") energy_calc_button.addActionListener(Calculate_Energy_Listener(self.scl_long_tuneup_controller)) energy_lbl = JLabel("<html>SCL Final E<SUB>kin</SUB>[MeV]=<html>",JLabel.RIGHT) self.energy_text = DoubleInputTextField(0.,DecimalFormat("####.#####"),12) energy_panel.add(energy_calc_button) energy_panel.add(energy_lbl) energy_panel.add(self.energy_text) #---- add to the main subpanel self.add(buttons_panel,BorderLayout.NORTH) self.add(energy_panel,BorderLayout.CENTER) self.add(wheel_panel,BorderLayout.SOUTH) #---- this is a holder for RF_Gap_Phases_Holder_for_Table_Selection self.rf_gap_phases_holder = null
def __init__(self,ws_scan_Record): self.isOn = true self.index = -1 self.pos = 0. self.fit_is_good = false self.gauss_sigma = ws_scan_Record.gauss_sigma self.ws_node = ws_scan_Record.ws_node self.ws_direction = ws_scan_Record.ws_direction self.custom_gauss_sigma = 0. self.custom_rms_sigma = 0. self.gd_wf = BasicGraphData() self.gd_fit_wf = BasicGraphData() self.gd_log_wf = BasicGraphData() self.gd_log_fit_wf = BasicGraphData() self.gd_wf.setDrawLinesOn(false) self.gd_log_wf.setDrawLinesOn(false) self.gd_fit_wf.setDrawPointsOn(false) self.gd_log_fit_wf.setDrawPointsOn(false) self.gd_wf.setGraphPointSize(5) self.gd_log_wf.setGraphPointSize(5) self.gd_fit_wf.setLineThick(3) self.gd_log_fit_wf.setLineThick(3) self.gd_wf.setGraphColor(Color.BLUE) self.gd_log_wf.setGraphColor(Color.BLUE) self.gd_fit_wf.setGraphColor(Color.RED) self.gd_log_fit_wf.setGraphColor(Color.RED) legendKey = GRAPH_LEGEND_KEY legendName = self.ws_node.getId() if(self.ws_direction == WS_DIRECTION_HOR): legendName += " Hor. " if(self.ws_direction == WS_DIRECTION_VER): legendName += " Ver. " self.gd_wf.setGraphProperty(legendKey,legendName+" Data") self.gd_log_wf.setGraphProperty(legendKey,"Log "+legendName+" Data ") self.gd_fit_wf.setGraphProperty(legendKey,"Log "+legendName+" Fit ") self.gd_log_fit_wf.setGraphProperty(legendKey,"Log "+legendName+" Fit ") #----------- copy Graph data ------------- for i in range(ws_scan_Record.gd_wf.getNumbOfPoints()): self.gd_wf.addPoint(ws_scan_Record.gd_wf.getX(i),ws_scan_Record.gd_wf.getY(i)) for i in range(ws_scan_Record.gd_log_wf.getNumbOfPoints()): self.gd_log_wf.addPoint(ws_scan_Record.gd_log_wf.getX(i),ws_scan_Record.gd_log_wf.getY(i)) self.n_fit_points = 150 self.quad_dict = {} self.cav_amp_phase_dict = {} self.param_dict = [self.quad_dict,self.cav_amp_phase_dict] #-----Gauss Fitting params---------------- self.CONST = DoubleInputTextField(0.,ScientificNumberFormat(5),10) self.A0 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) self.X_CENTER = DoubleInputTextField(0.,ScientificNumberFormat(5),10) self.SIGMA = DoubleInputTextField(self.gauss_sigma,ScientificNumberFormat(5),10) self.X_MIN = DoubleInputTextField(ws_scan_Record.left_limit,ScientificNumberFormat(5),10) self.X_MAX = DoubleInputTextField(ws_scan_Record.right_limit,ScientificNumberFormat(5),10)
class WS_Scan_and_Fit_Record: def __init__(self,ws_scan_Record): self.isOn = true self.index = -1 self.pos = 0. self.fit_is_good = false self.gauss_sigma = ws_scan_Record.gauss_sigma self.ws_node = ws_scan_Record.ws_node self.ws_direction = ws_scan_Record.ws_direction self.custom_gauss_sigma = 0. self.custom_rms_sigma = 0. self.gd_wf = BasicGraphData() self.gd_fit_wf = BasicGraphData() self.gd_log_wf = BasicGraphData() self.gd_log_fit_wf = BasicGraphData() self.gd_wf.setDrawLinesOn(false) self.gd_log_wf.setDrawLinesOn(false) self.gd_fit_wf.setDrawPointsOn(false) self.gd_log_fit_wf.setDrawPointsOn(false) self.gd_wf.setGraphPointSize(5) self.gd_log_wf.setGraphPointSize(5) self.gd_fit_wf.setLineThick(3) self.gd_log_fit_wf.setLineThick(3) self.gd_wf.setGraphColor(Color.BLUE) self.gd_log_wf.setGraphColor(Color.BLUE) self.gd_fit_wf.setGraphColor(Color.RED) self.gd_log_fit_wf.setGraphColor(Color.RED) legendKey = GRAPH_LEGEND_KEY legendName = self.ws_node.getId() if(self.ws_direction == WS_DIRECTION_HOR): legendName += " Hor. " if(self.ws_direction == WS_DIRECTION_VER): legendName += " Ver. " self.gd_wf.setGraphProperty(legendKey,legendName+" Data") self.gd_log_wf.setGraphProperty(legendKey,"Log "+legendName+" Data ") self.gd_fit_wf.setGraphProperty(legendKey,"Log "+legendName+" Fit ") self.gd_log_fit_wf.setGraphProperty(legendKey,"Log "+legendName+" Fit ") #----------- copy Graph data ------------- for i in range(ws_scan_Record.gd_wf.getNumbOfPoints()): self.gd_wf.addPoint(ws_scan_Record.gd_wf.getX(i),ws_scan_Record.gd_wf.getY(i)) for i in range(ws_scan_Record.gd_log_wf.getNumbOfPoints()): self.gd_log_wf.addPoint(ws_scan_Record.gd_log_wf.getX(i),ws_scan_Record.gd_log_wf.getY(i)) self.n_fit_points = 150 self.quad_dict = {} self.cav_amp_phase_dict = {} self.param_dict = [self.quad_dict,self.cav_amp_phase_dict] #-----Gauss Fitting params---------------- self.CONST = DoubleInputTextField(0.,ScientificNumberFormat(5),10) self.A0 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) self.X_CENTER = DoubleInputTextField(0.,ScientificNumberFormat(5),10) self.SIGMA = DoubleInputTextField(self.gauss_sigma,ScientificNumberFormat(5),10) self.X_MIN = DoubleInputTextField(ws_scan_Record.left_limit,ScientificNumberFormat(5),10) self.X_MAX = DoubleInputTextField(ws_scan_Record.right_limit,ScientificNumberFormat(5),10) def plotFitData(self): x_min = self.X_MIN.getValue() x_max = self.X_MAX.getValue() step = (x_max - x_min)/(self.n_fit_points - 1) base = self.CONST.getValue() a0 = self.A0.getValue() x0 = self.X_CENTER.getValue() sigma2 = (self.SIGMA.getValue())**2 self.gd_fit_wf.removeAllPoints() self.gd_log_fit_wf.removeAllPoints() for i in range(self.n_fit_points): x = x_min + i*step y = base + a0*math.exp(-(x-x0)**2/(2*sigma2)) self.gd_fit_wf.addPoint(x,y) if(y > 0.): self.gd_log_fit_wf.addPoint(x,math.log(y)) def setParamDict(self,param_dict): self.param_dict = param_dict [self.quad_dict,self.cav_amp_phase_dict] = self.param_dict def getName(self): return self.ws_node.getId() def getAccNode(self): return self.ws_node def updateGaussParams(self): self.custom_gauss_sigma = self.SIGMA.getValue()
def __init__(self): LabelDoulbeTextFieldPanel.__init__(self,3,2) dbl_text_filed1 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) dbl_text_filed2 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) dbl_text_filed3 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) dbl_text_filed4 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) dbl_text_filed5 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) dbl_text_filed6 = DoubleInputTextField(0.,ScientificNumberFormat(5),10) dbl_text_filed1.setValueQuietly(0.) dbl_text_filed2.setValueQuietly(0.) dbl_text_filed3.setValueQuietly(0.) dbl_text_filed4.setValueQuietly(0.) dbl_text_filed5.setValueQuietly(0.) dbl_text_filed6.setValueQuietly(0.) dbl_text_filed1.setAlertBackground(Color.white) dbl_text_filed2.setAlertBackground(Color.white) dbl_text_filed3.setAlertBackground(Color.white) dbl_text_filed4.setAlertBackground(Color.white) dbl_text_filed5.setAlertBackground(Color.white) dbl_text_filed6.setAlertBackground(Color.white) self.addLabelAndText("const" ,dbl_text_filed1) self.addLabelAndText("A0" ,dbl_text_filed2) self.addLabelAndText("X center",dbl_text_filed3) self.addLabelAndText("sigma" ,dbl_text_filed4) self.addLabelAndText("x_min" ,dbl_text_filed5) self.addLabelAndText("x_max" ,dbl_text_filed6)
class Abstract_Cavity_Controller: def __init__(self,main_loop_controller,cav_wrapper): self.main_loop_controller = main_loop_controller self.cav_wrapper = cav_wrapper self.main_panel = JPanel(BorderLayout()) self.parameters_panel = JPanel(BorderLayout()) #---- backward cavity amplitude move params panel0 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) cav_amp_backward_steps_mult_label = JLabel("N cav. amp. backward steps multiplier =",JLabel.RIGHT) self.cav_amp_backward_steps_mult_text = DoubleInputTextField(1.0,ScientificNumberFormat(2),5) panel0.add(cav_amp_backward_steps_mult_label) panel0.add(self.cav_amp_backward_steps_mult_text) #---- cavity's wait time multiplier panel1 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) cav_amp_wait_time_mult_label = JLabel("Cav. amp. time wait multiplier =",JLabel.RIGHT) self.cav_amp_wait_time_mult_text = DoubleInputTextField(3.0,ScientificNumberFormat(2),5) panel1.add(cav_amp_wait_time_mult_label) panel1.add(self.cav_amp_wait_time_mult_text) #---- cavity's safe amplitude up and down limits panel2 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) safe_relative_amp_up_label = JLabel("Cav. amp. safe Up [%]=",JLabel.RIGHT) self.safe_relative_amp_up_text = DoubleInputTextField(7.0,ScientificNumberFormat(2),5) panel2.add(safe_relative_amp_up_label) panel2.add(self.safe_relative_amp_up_text) panel3 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) safe_relative_amp_down_label = JLabel("Cav. amp. safe Down [%]=",JLabel.RIGHT) self.safe_relative_amp_down_text = DoubleInputTextField(7.0,ScientificNumberFormat(2),5) panel3.add(safe_relative_amp_down_label) panel3.add(self.safe_relative_amp_down_text) #----- cavity's guess phase[deg] and amplitude[%] corrections after 360 deg full scan for inner BPMs panel4 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) guess_phase_shift_label = JLabel("Cav. Guess Phase Shift after Full Scan [deg]=",JLabel.RIGHT) self.guess_phase_shift_text = DoubleInputTextField(0.0,ScientificNumberFormat(2),5) panel4.add(guess_phase_shift_label) panel4.add(self.guess_phase_shift_text) panel5 = JPanel(FlowLayout(FlowLayout.LEFT,1,3)) guess_cav_amp_shift_label = JLabel("Cav. Amp Shift after Full Scan [%]=",JLabel.RIGHT) self.guess_cav_amp_shift_text = DoubleInputTextField(0.0,ScientificNumberFormat(2),5) panel5.add(guess_cav_amp_shift_label) panel5.add(self.guess_cav_amp_shift_text) #----------------------------------------------- params_panel = JPanel(GridLayout(6,1,1,1)) params_panel.add(panel0) params_panel.add(panel1) params_panel.add(panel2) params_panel.add(panel3) params_panel.add(panel4) params_panel.add(panel5) #------------------------------------------------ self.parameters_panel.add(params_panel,BorderLayout.NORTH) #------------------------------------------------ self.scan_progress_bar = Scan_Progress_Bar(self.main_loop_controller,self) #------------------------------------------------ cav_wrapper.safe_relative_amp_up_text = self.safe_relative_amp_up_text cav_wrapper.safe_relative_amp_down_text = self.safe_relative_amp_down_text def getMainPanel(self): return self.main_panel def getParamsPanel(self): return self.parameters_panel def getScanProgressBarPanel(self): return self.scan_progress_bar.scan_progress_panel def getScanProgressBar(self): return self.scan_progress_bar def runSetUpAlgorithm(self): """ Returns (true, text) in the case of the success """ text = "Good. Cav="+self.cav_wrapper.alias return (true,text) def init(self): """ reads the pv values """ self.cav_wrapper.init() self.scan_progress_bar.init() def writeDataToXML(self,root_da): """ Abstract method. This method should be implemented in the subclass """ cav_cntrl_data_da = root_da.createChild("CAVITY_CONTROLLER_"+self.cav_wrapper.alias) def readDataFromXML(self,cav_cntrl_data_da): """ Abstract method. This method should be implemented in the subclass """ pass def checkBPM_Usage(self,bpm_wrapper): """ Abstract method. Returns True or False about this controller usage of the BPM """ return false def timeSleep(self, time_sleep): n_parts = 5 tm = time_sleep/n_parts for ind in range(n_parts): time.sleep(tm) self.scan_progress_bar.count_and_update(tm) if(self.main_loop_controller.loop_run_state.shouldStop): return def setMaxTimeCount(self): """ Abstract method. It should be implemented in each subclass. It returns the maximal time count. """ print "Debug. Abstract_Cavity_Controller.setMaxTimeCount() This method should be implemented in a subclass." self.scan_progress_bar.setMaxTimeCount(100.) return self.scan_progress_bar.count_max def getPastaFittingTime(self): """ Abstract method. It should be implemented in each subclass. """ return 0. def initProgressBar(self): self.scan_progress_bar.init() def wrtiteAbstractCntrlToXML(self,root_da): abstr_cntrl_data_da = root_da.createChild("ABSTRACT_CAVITY_CONTROLLER_PARAMS") abstr_cntrl_data_da.setValue("amp_steps_mult",self.cav_amp_backward_steps_mult_text.getValue()) abstr_cntrl_data_da.setValue("amp_time_mult",self.cav_amp_wait_time_mult_text.getValue()) abstr_cntrl_data_da.setValue("amp_safe_up_percent",self.safe_relative_amp_up_text.getValue()) abstr_cntrl_data_da.setValue("amp_safe_down_percent",self.safe_relative_amp_down_text.getValue()) abstr_cntrl_data_da.setValue("guess_phase_shift",self.guess_phase_shift_text.getValue()) abstr_cntrl_data_da.setValue("guess_amp_shift_percent",self.guess_cav_amp_shift_text.getValue()) def readAbstractCntrlFromXML(self,root_da): abstr_cntrl_data_da = root_da.childAdaptor("ABSTRACT_CAVITY_CONTROLLER_PARAMS") self.cav_amp_backward_steps_mult_text.setValue(abstr_cntrl_data_da.doubleValue("amp_steps_mult")) self.cav_amp_wait_time_mult_text.setValue(abstr_cntrl_data_da.doubleValue("amp_time_mult")) if(abstr_cntrl_data_da.hasAttribute("amp_safe_up_percent")): self.safe_relative_amp_up_text.setValue(abstr_cntrl_data_da.doubleValue("amp_safe_up_percent")) if(abstr_cntrl_data_da.hasAttribute("amp_safe_down_percent")): self.safe_relative_amp_down_text.setValue(abstr_cntrl_data_da.doubleValue("amp_safe_down_percent")) if(abstr_cntrl_data_da.hasAttribute("guess_phase_shift")): self.guess_phase_shift_text.setValue(abstr_cntrl_data_da.doubleValue("guess_phase_shift")) if(abstr_cntrl_data_da.hasAttribute("guess_amp_shift_percent")): self.guess_cav_amp_shift_text.setValue(abstr_cntrl_data_da.doubleValue("guess_amp_shift_percent"))
def __init__(self, main_loop_controller, cav_wrapper): self.main_loop_controller = main_loop_controller self.cav_wrapper = cav_wrapper self.main_panel = JPanel(BorderLayout()) self.parameters_panel = JPanel(BorderLayout()) #---- backward cavity amplitude move params panel0 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) cav_amp_backward_steps_mult_label = JLabel( "N cav. amp. backward steps multiplier =", JLabel.RIGHT) self.cav_amp_backward_steps_mult_text = DoubleInputTextField( 1.0, ScientificNumberFormat(2), 5) panel0.add(cav_amp_backward_steps_mult_label) panel0.add(self.cav_amp_backward_steps_mult_text) #---- cavity's wait time multiplier panel1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) cav_amp_wait_time_mult_label = JLabel( "Cav. amp. time wait multiplier =", JLabel.RIGHT) self.cav_amp_wait_time_mult_text = DoubleInputTextField( 3.0, ScientificNumberFormat(2), 5) panel1.add(cav_amp_wait_time_mult_label) panel1.add(self.cav_amp_wait_time_mult_text) #---- cavity's safe amplitude up and down limits panel2 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) safe_relative_amp_up_label = JLabel("Cav. amp. safe Up [%]=", JLabel.RIGHT) self.safe_relative_amp_up_text = DoubleInputTextField( 7.0, ScientificNumberFormat(2), 5) panel2.add(safe_relative_amp_up_label) panel2.add(self.safe_relative_amp_up_text) panel3 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) safe_relative_amp_down_label = JLabel("Cav. amp. safe Down [%]=", JLabel.RIGHT) self.safe_relative_amp_down_text = DoubleInputTextField( 7.0, ScientificNumberFormat(2), 5) panel3.add(safe_relative_amp_down_label) panel3.add(self.safe_relative_amp_down_text) #----- cavity's guess phase[deg] and amplitude[%] corrections after 360 deg full scan for inner BPMs panel4 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) guess_phase_shift_label = JLabel( "Cav. Guess Phase Shift after Full Scan [deg]=", JLabel.RIGHT) self.guess_phase_shift_text = DoubleInputTextField( 0.0, ScientificNumberFormat(2), 5) panel4.add(guess_phase_shift_label) panel4.add(self.guess_phase_shift_text) panel5 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) guess_cav_amp_shift_label = JLabel( "Cav. Amp Shift after Full Scan [%]=", JLabel.RIGHT) self.guess_cav_amp_shift_text = DoubleInputTextField( 0.0, ScientificNumberFormat(2), 5) panel5.add(guess_cav_amp_shift_label) panel5.add(self.guess_cav_amp_shift_text) #----------------------------------------------- params_panel = JPanel(GridLayout(6, 1, 1, 1)) params_panel.add(panel0) params_panel.add(panel1) params_panel.add(panel2) params_panel.add(panel3) params_panel.add(panel4) params_panel.add(panel5) #------------------------------------------------ self.parameters_panel.add(params_panel, BorderLayout.NORTH) #------------------------------------------------ self.scan_progress_bar = Scan_Progress_Bar(self.main_loop_controller, self) #------------------------------------------------ cav_wrapper.safe_relative_amp_up_text = self.safe_relative_amp_up_text cav_wrapper.safe_relative_amp_down_text = self.safe_relative_amp_down_text
def __init__(self, scl_long_tuneup_controller): #--- scl_long_tuneup_controller the parent document for all SCL tune up controllers self.scl_long_tuneup_controller = scl_long_tuneup_controller #----etched border etched_border = BorderFactory.createEtchedBorder() #----main panel self.main_panel = JPanel(BorderLayout()) #------top params panel----------------------- right_info_panel = JPanel(BorderLayout()) right_top_control_panel = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) analysis_button = JButton("Find BAD Points") analysis_button.addActionListener(Analyze_Data_Button_Listener(self)) right_top_control_panel.add(analysis_button) #------ maximal bpm phase error after the scan max_phase_err_lbl = JLabel("Max BPM Phase Err = ", JLabel.RIGHT) self.max_phase_err_text = DoubleInputTextField(10.0, DecimalFormat("##.#"), 5) right_top_control_panel.add(max_phase_err_lbl) right_top_control_panel.add(self.max_phase_err_text) #----------------------------------------------- right_bottom_control_panel = JPanel(BorderLayout()) right_bottom_control_panel0 = JPanel(BorderLayout()) right_bottom_control_panel1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) right_bottom_control_panel.add(right_bottom_control_panel0, BorderLayout.NORTH) right_bottom_control_panel.add(right_bottom_control_panel1, BorderLayout.SOUTH) statistics_of_errors_lbl = JLabel("Statistics:", JLabel.RIGHT) self.statistics_of_errors_txt = JTextField() right_bottom_control_panel0.add(statistics_of_errors_lbl, BorderLayout.WEST) right_bottom_control_panel0.add(self.statistics_of_errors_txt, BorderLayout.CENTER) remove_worst_points_button = JButton("Remove Worst Points") remove_worst_points_button.addActionListener( CleanUp_Worst_Phase_Points_Data_Button_Listener(self)) remove_all_bad_bpms_button = JButton("Remove All Bad BPMs") remove_all_bad_bpms_button.addActionListener( CleanUp_All_Bad_BPMs_Button_Listener(self)) right_bottom_control_panel1.add(remove_worst_points_button) right_bottom_control_panel1.add(remove_all_bad_bpms_button) #----------------------------------------------- right_tables_panel = JPanel(GridLayout(1, 3)) right_info_panel.add(right_top_control_panel, BorderLayout.NORTH) right_info_panel.add(right_tables_panel, BorderLayout.CENTER) right_info_panel.add(right_bottom_control_panel, BorderLayout.SOUTH) self.main_panel.add(right_info_panel, BorderLayout.EAST) #------cavities scan table panel -------- self.bad_bpms_amp_phase_graphs_panel = Bad_BPMs_Amp_Phase_Graphs_Panel( self) self.main_panel.add(self.bad_bpms_amp_phase_graphs_panel, BorderLayout.CENTER) #------ let's make tables for a list of cavities, bpms, and bad points indexes self.cavs_with_bad_data_table_model = Cavs_with_Bad_PhaseScan_Table_Model( self) self.cavs_table = JTable(self.cavs_with_bad_data_table_model) self.cavs_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.cavs_table.setFillsViewportHeight(true) self.cavs_table.setPreferredScrollableViewportSize(Dimension(180, 300)) self.cavs_table.getSelectionModel().addListSelectionListener( Cavs_Table_Selection_Listener(self)) self.bpms_table_model = Bad_PhaseScan_BPMs_Table_Model(self) self.bpms_table = JTable(self.bpms_table_model) self.bpms_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.bpms_table.setFillsViewportHeight(true) self.bpms_table.getSelectionModel().addListSelectionListener( BPMs_Table_Selection_Listener(self)) self.bpms_table.setPreferredScrollableViewportSize(Dimension(180, 300)) self.points_table_model = Bad_Points_Table_Model(self) self.points_table = JTable(self.points_table_model) self.points_table.setFillsViewportHeight(true) self.points_table.setPreferredScrollableViewportSize( Dimension(180, 300)) #----- set scroll panes scrl_panel0 = JScrollPane(self.cavs_table) scrl_panel1 = JScrollPane(self.bpms_table) scrl_panel2 = JScrollPane(self.points_table) scrl_panel0.setBorder( BorderFactory.createTitledBorder(etched_border, "Cavs")) scrl_panel1.setBorder( BorderFactory.createTitledBorder(etched_border, "BPMs")) scrl_panel2.setBorder( BorderFactory.createTitledBorder(etched_border, "Bad Points")) right_tables_panel.setBorder(etched_border) right_tables_panel.add(scrl_panel0) right_tables_panel.add(scrl_panel1) right_tables_panel.add(scrl_panel2) #----- dictionary with the bad data self.cavs_to_bpm_dict[cav_wrapper] = [bpm_wrappers,bpms_to_points_dict] self.cavs_to_bpm_dict = {} #----- arrays with bad data for the tables self.cavs_with_bad_data_arr = [] self.bpms_arr = [] self.points_arr = []
def __init__(self,linac_wizard_document,transverse_twiss_fitting_controller): self.linac_wizard_document = linac_wizard_document self.transverse_twiss_fitting_controller = transverse_twiss_fitting_controller self.main_panel = JPanel(BorderLayout()) tmp_panel = JPanel(GridLayout(7,2)) self.eKin_text = DoubleInputTextField(0.,ScientificNumberFormat(7),8) eKin_lbl = JLabel("eKin[MeV]=",JLabel.RIGHT) self.current_text = DoubleInputTextField(0.,ScientificNumberFormat(4),8) current_lbl = JLabel("Curr.[mA]=",JLabel.RIGHT) self.fit_err_text = DoubleInputTextField(0.,ScientificNumberFormat(4),8) fit_err_lbl = JLabel("Fit Err,%=",JLabel.RIGHT) self.fit_err_text.setValue(5.0) self.fit_iter_text = DoubleInputTextField(0.,ScientificNumberFormat(1),8) iter_lbl = JLabel("Fit Iterations=",JLabel.RIGHT) self.fit_iter_text.setValue(200) self.fit_iter_left_text = DoubleInputTextField(0.,ScientificNumberFormat(1),8) iter_left_lbl = JLabel("Iters. Left=",JLabel.RIGHT) self.avg_diff_text = DoubleInputTextField(0.,ScientificNumberFormat(7),8) avg_diff_lbl = JLabel("Avg.Diff.[mm]=",JLabel.RIGHT) tmp_panel.add(eKin_lbl) tmp_panel.add(self.eKin_text) tmp_panel.add(current_lbl) tmp_panel.add(self.current_text) tmp_panel.add(fit_err_lbl) tmp_panel.add(self.fit_err_text) tmp0_lbl = JLabel("==========",JLabel.RIGHT) tmp1_lbl = JLabel("==========",JLabel.RIGHT) tmp_panel.add(tmp0_lbl) tmp_panel.add(tmp1_lbl) tmp_panel.add(iter_lbl) tmp_panel.add(self.fit_iter_text) tmp_panel.add(iter_left_lbl) tmp_panel.add(self.fit_iter_left_text) tmp_panel.add(avg_diff_lbl) tmp_panel.add(self.avg_diff_text) #----etched border etched_border = BorderFactory.createEtchedBorder() #------buttons panel ------------ one_pass_button = JButton("Make One Pass") one_pass_button.addActionListener(One_Pass_Listener(self.linac_wizard_document)) fit_button = JButton("Start Fitting") fit_button.addActionListener(Twiss_Fitting_Listener(self.linac_wizard_document)) stop_fit_button = JButton("Stop Fitting") stop_fit_button.addActionListener(Stop_Twiss_Fitting_Listener(self.linac_wizard_document)) buttons_panel = JPanel(GridLayout(3,1)) button0_panel = JPanel(FlowLayout(FlowLayout.CENTER,3,3)) button0_panel.add(one_pass_button) button1_panel = JPanel(FlowLayout(FlowLayout.CENTER,3,3)) button1_panel.add(fit_button) button2_panel = JPanel(FlowLayout(FlowLayout.CENTER,3,3)) button2_panel.add(stop_fit_button) buttons_panel.add(button0_panel) buttons_panel.add(button1_panel) buttons_panel.add(button2_panel) #--------- Final Twiss parameters table ----- self.final_twiss_params_holder = Twiss_Params_Holder() self.finalTwiss_table = JTable(Final_Twiss_Table_Model(self.final_twiss_params_holder)) self.finalTwiss_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.finalTwiss_table.setFillsViewportHeight(true) self.finalTwiss_table.setPreferredScrollableViewportSize(Dimension(180,80)) final_to_init_button = JButton("Copy Results To Initial Twiss") final_to_init_button.addActionListener(Copy_Twiss_Listener(self.transverse_twiss_fitting_controller)) button2_panel = JPanel(FlowLayout(FlowLayout.CENTER,3,3)) button2_panel.add(final_to_init_button) finalTwiss_panel = JPanel(BorderLayout()) finalTwiss_panel.add(JScrollPane(self.finalTwiss_table), BorderLayout.CENTER) finalTwiss_panel.add(button2_panel,BorderLayout.SOUTH) border = BorderFactory.createTitledBorder(etched_border,"Final Twiss Fitting Results") finalTwiss_panel.setBorder(border) #---------make main panel -------------- tmp1_panel = JPanel(BorderLayout()) tmp1_panel.add(tmp_panel,BorderLayout.NORTH) tmp1_panel.add(buttons_panel,BorderLayout.SOUTH) tmp2_panel = JPanel(BorderLayout()) tmp2_panel.add(tmp1_panel,BorderLayout.WEST) tmp2_panel.add(finalTwiss_panel,BorderLayout.CENTER) self.main_panel.add(tmp2_panel,BorderLayout.NORTH)
from xal.extension.widgets.swing import DoubleInputTextField from xal.tools.text import ScientificNumberFormat false = Boolean("false").booleanValue() true = Boolean("true").booleanValue() null = None #window closer will kill this apps class WindowCloser(WindowAdapter): def windowClosing(self, windowEvent): sys.exit(1) buffer_size_text = DoubleInputTextField(5.0, ScientificNumberFormat(1), 10) class Event_Checker: def __init__(self, event_handler, min_limit_text, max_limit_text): self.event_handler = event_handler self.min_limit_text = min_limit_text self.max_limit_text = max_limit_text def checkEvent(self, buffer_holder): buff_arr = buffer_holder.buff_arr #print "debug checkEvent buff_arr=",buff_arr [time_in, val_arr, date_time] = buff_arr[len(buff_arr) / 2] #print "debug checkEvent val_arr=",val_arr n_vals = len(val_arr) val_ind = n_vals / 2
def __init__(self,dtl_acceptance_scans_controller,dtl_acc_scan_cavity_controller): self.dtl_acceptance_scans_controller = dtl_acceptance_scans_controller self.main_loop_controller = self.dtl_acceptance_scans_controller.main_loop_controller self.dtl_acc_scan_cavity_controller = dtl_acc_scan_cavity_controller self.setLayout(BorderLayout()) self.setBorder(BorderFactory.createEtchedBorder()) etched_border = BorderFactory.createEtchedBorder() #---------------------------------------------------- scan_params_panel_1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) scan_params_panel_1.setBorder(BorderFactory.createEtchedBorder()) scan_params_panel_1.setBorder(BorderFactory.createTitledBorder(etched_border,"Cavity Amplitude Scan Parameters")) scan_params_panel_2 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) scan_params_panel_2.setBorder(BorderFactory.createTitledBorder(etched_border,"Cavity Phase Scan Parameters")) scan_params_panel_3 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) scan_params_panel_3.setBorder(BorderFactory.createTitledBorder(etched_border,"Cavity Live Parameters")) self.scan_cav_amplitude_button = JRadioButton("Scan Ampl.") scan_params_panel_1.add(self.scan_cav_amplitude_button) #------------------------------------------------------------ min_cav_amp_label = JLabel(" Min=",JLabel.RIGHT) max_cav_amp_label = JLabel(" Max=",JLabel.RIGHT) cav_amp_points_label = JLabel(" Points=",JLabel.RIGHT) time_amp_scan_label = JLabel(" Ampl. Change Time[sec]=",JLabel.RIGHT) self.min_cav_amp_text = DoubleInputTextField(0.,DecimalFormat("#.####"),5) self.max_cav_amp_text = DoubleInputTextField(0.,DecimalFormat("#.####"),5) self.cav_amp_points_text = DoubleInputTextField(3,DecimalFormat("##"),3) self.time_amp_scan_text = DoubleInputTextField(20.,DecimalFormat("###"),3) scan_params_panel_1.add(min_cav_amp_label) scan_params_panel_1.add(self.min_cav_amp_text) scan_params_panel_1.add(max_cav_amp_label) scan_params_panel_1.add(self.max_cav_amp_text) scan_params_panel_1.add(cav_amp_points_label) scan_params_panel_1.add(self.cav_amp_points_text) scan_params_panel_1.add(time_amp_scan_label) scan_params_panel_1.add(self.time_amp_scan_text) #---------------------------------------------- phase_step_label = JLabel("Step[deg]=",JLabel.RIGHT) phase_min_label = JLabel(" Min[deg]=",JLabel.RIGHT) phase_max_label = JLabel(" Max[deg]=",JLabel.RIGHT) phase_scan_time_step_label = JLabel(" Time/Step[sec]=",JLabel.RIGHT) self.phase_step_text = DoubleInputTextField(3.,DecimalFormat("##.##"),5) self.phase_min_text = DoubleInputTextField(-180.,DecimalFormat("####.#"),6) self.phase_max_text = DoubleInputTextField(180.,DecimalFormat("####.#"),6) self.phase_scan_time_step_text = DoubleInputTextField(1.5,DecimalFormat("##.#"),4) scan_params_panel_2.add(phase_step_label) scan_params_panel_2.add(self.phase_step_text) scan_params_panel_2.add(phase_min_label) scan_params_panel_2.add(self.phase_min_text) scan_params_panel_2.add(phase_max_label) scan_params_panel_2.add(self.phase_max_text) scan_params_panel_2.add(phase_scan_time_step_label) scan_params_panel_2.add(self.phase_scan_time_step_text) #---------------------------------------------- cav_ampl_live_label = JLabel("Cavity Ampl.=",JLabel.RIGHT) cav_phase_live_label = JLabel(" Phase[deg]=",JLabel.RIGHT) self.cav_ampl_live_text = DoubleInputTextField(0.,DecimalFormat("#.###"),5) self.cav_phase_live_text = DoubleInputTextField(0.,DecimalFormat("####.##"),7) scan_params_panel_3.add(cav_ampl_live_label) scan_params_panel_3.add(self.cav_ampl_live_text) scan_params_panel_3.add(cav_phase_live_label) scan_params_panel_3.add(self.cav_phase_live_text) #----------------------------------------------- cntrl_upper_panel = JPanel(GridLayout(3,1,1,1)) cntrl_upper_panel.add(scan_params_panel_1) cntrl_upper_panel.add(scan_params_panel_2) cntrl_upper_panel.add(scan_params_panel_3) #---------------------------------------------- scan_res_panel = JPanel(BorderLayout()) #---------------------------------------------- left_scan_res_panel_0 = JPanel(BorderLayout()) scan_progress_panel = self.dtl_acc_scan_cavity_controller.scan_progress_bar.scan_progress_panel left_scan_res_panel_0.add(scan_progress_panel,BorderLayout.CENTER) #--------------------------------------------- left_scan_res_panel_1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) make_analysis_button = JButton("Make Analysis") make_analysis_button.addActionListener(Make_Analysis_Of_Scan_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) set_new_phase_button = JButton("Set New Phase to EPICS") set_new_phase_button.addActionListener(Set_New_Phase_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) left_scan_res_panel_1.add(make_analysis_button) left_scan_res_panel_1.add(set_new_phase_button) #---------------------------------------------- left_scan_res_panel_2 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) new_cav_phase_label = JLabel("New Phase[deg]=",JLabel.RIGHT) self.new_cav_phase_text = DoubleInputTextField(0.,DecimalFormat("####.##"),7) left_scan_res_panel_2.add(new_cav_phase_label) left_scan_res_panel_2.add(self.new_cav_phase_text) #---------------------------------------------- left_scan_res_panel_3 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) shift_scan_button = JButton("Shift Scan by +10 deg") shift_scan_button.addActionListener(Shift_Scan_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) make_pattern_button = JButton("Make a Pattern") make_pattern_button.addActionListener(Make_Pattern_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) left_scan_res_panel_3.add(shift_scan_button) left_scan_res_panel_3.add(make_pattern_button) #---------------------------------------------- left_scan_res_panel_4 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) acc_scan_width_label = JLabel("Acc. Scan Width[deg]=",JLabel.RIGHT) self.acc_scan_width_text = DoubleInputTextField(0.,DecimalFormat("####.##"),7) left_scan_res_panel_4.add(acc_scan_width_label) left_scan_res_panel_4.add(self.acc_scan_width_text) #---------------------------------------------- left_scan_res_panel_5 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) new_cav_amp_label = JLabel("New Cav. Amplitude =",JLabel.RIGHT) self.new_cav_amp_text = DoubleInputTextField(0.,DecimalFormat("#.####"),7) left_scan_res_panel_5.add(new_cav_amp_label) left_scan_res_panel_5.add(self.new_cav_amp_text) #---------------------------------------------- scan_res_grid_panel = JPanel(GridLayout(6,1,1,1)) scan_res_grid_panel.add(left_scan_res_panel_0) scan_res_grid_panel.add(left_scan_res_panel_1) scan_res_grid_panel.add(left_scan_res_panel_2) scan_res_grid_panel.add(left_scan_res_panel_3) scan_res_grid_panel.add(left_scan_res_panel_4) scan_res_grid_panel.add(left_scan_res_panel_5) scan_res_panel.add(scan_res_grid_panel,BorderLayout.NORTH) #---------------------------------------------- self.scan_data_graph = Acceptance_Graphs_Panel_Holder(self.dtl_acceptance_scans_controller) self.add(cntrl_upper_panel,BorderLayout.NORTH) self.add(self.scan_data_graph.getGraphsPanel(),BorderLayout.CENTER) self.add(scan_res_panel,BorderLayout.WEST)
def __init__(self,ws_lw_acquisition_controller): self.ws_lw_acquisition_controller = ws_lw_acquisition_controller self.dbltxt_arr = [] for i in range(6): self.dbltxt_arr.append(DoubleInputTextField("0."))
def __init__(self, linac_wizard_document, transverse_twiss_fitting_controller): self.linac_wizard_document = linac_wizard_document self.transverse_twiss_fitting_controller = transverse_twiss_fitting_controller self.main_panel = JPanel(BorderLayout()) tmp_panel = JPanel(GridLayout(7, 2)) self.eKin_text = DoubleInputTextField(0., ScientificNumberFormat(7), 8) eKin_lbl = JLabel("eKin[MeV]=", JLabel.RIGHT) self.current_text = DoubleInputTextField(0., ScientificNumberFormat(4), 8) current_lbl = JLabel("Curr.[mA]=", JLabel.RIGHT) self.fit_err_text = DoubleInputTextField(0., ScientificNumberFormat(4), 8) fit_err_lbl = JLabel("Fit Err,%=", JLabel.RIGHT) self.fit_err_text.setValue(5.0) self.fit_iter_text = DoubleInputTextField(0., ScientificNumberFormat(1), 8) iter_lbl = JLabel("Fit Iterations=", JLabel.RIGHT) self.fit_iter_text.setValue(200) self.fit_iter_left_text = DoubleInputTextField( 0., ScientificNumberFormat(1), 8) iter_left_lbl = JLabel("Iters. Left=", JLabel.RIGHT) self.avg_diff_text = DoubleInputTextField(0., ScientificNumberFormat(7), 8) avg_diff_lbl = JLabel("Avg.Diff.[mm]=", JLabel.RIGHT) tmp_panel.add(eKin_lbl) tmp_panel.add(self.eKin_text) tmp_panel.add(current_lbl) tmp_panel.add(self.current_text) tmp_panel.add(fit_err_lbl) tmp_panel.add(self.fit_err_text) tmp0_lbl = JLabel("==========", JLabel.RIGHT) tmp1_lbl = JLabel("==========", JLabel.RIGHT) tmp_panel.add(tmp0_lbl) tmp_panel.add(tmp1_lbl) tmp_panel.add(iter_lbl) tmp_panel.add(self.fit_iter_text) tmp_panel.add(iter_left_lbl) tmp_panel.add(self.fit_iter_left_text) tmp_panel.add(avg_diff_lbl) tmp_panel.add(self.avg_diff_text) #----etched border etched_border = BorderFactory.createEtchedBorder() #------buttons panel ------------ one_pass_button = JButton("Make One Pass") one_pass_button.addActionListener( One_Pass_Listener(self.linac_wizard_document)) fit_button = JButton("Start Fitting") fit_button.addActionListener( Twiss_Fitting_Listener(self.linac_wizard_document)) stop_fit_button = JButton("Stop Fitting") stop_fit_button.addActionListener( Stop_Twiss_Fitting_Listener(self.linac_wizard_document)) buttons_panel = JPanel(GridLayout(3, 1)) button0_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button0_panel.add(one_pass_button) button1_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button1_panel.add(fit_button) button2_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button2_panel.add(stop_fit_button) buttons_panel.add(button0_panel) buttons_panel.add(button1_panel) buttons_panel.add(button2_panel) #--------- Final Twiss parameters table ----- self.final_twiss_params_holder = Twiss_Params_Holder() self.finalTwiss_table = JTable( Final_Twiss_Table_Model(self.final_twiss_params_holder)) self.finalTwiss_table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION) self.finalTwiss_table.setFillsViewportHeight(true) self.finalTwiss_table.setPreferredScrollableViewportSize( Dimension(180, 80)) final_to_init_button = JButton("Copy Results To Initial Twiss") final_to_init_button.addActionListener( Copy_Twiss_Listener(self.transverse_twiss_fitting_controller)) button2_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button2_panel.add(final_to_init_button) finalTwiss_panel = JPanel(BorderLayout()) finalTwiss_panel.add(JScrollPane(self.finalTwiss_table), BorderLayout.CENTER) finalTwiss_panel.add(button2_panel, BorderLayout.SOUTH) border = BorderFactory.createTitledBorder( etched_border, "Final Twiss Fitting Results") finalTwiss_panel.setBorder(border) #---------make main panel -------------- tmp1_panel = JPanel(BorderLayout()) tmp1_panel.add(tmp_panel, BorderLayout.NORTH) tmp1_panel.add(buttons_panel, BorderLayout.SOUTH) tmp2_panel = JPanel(BorderLayout()) tmp2_panel.add(tmp1_panel, BorderLayout.WEST) tmp2_panel.add(finalTwiss_panel, BorderLayout.CENTER) self.main_panel.add(tmp2_panel, BorderLayout.NORTH)
class Abstract_Cavity_Controller: def __init__(self, main_loop_controller, cav_wrapper): self.main_loop_controller = main_loop_controller self.cav_wrapper = cav_wrapper self.main_panel = JPanel(BorderLayout()) self.parameters_panel = JPanel(BorderLayout()) #---- backward cavity amplitude move params panel0 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) cav_amp_backward_steps_mult_label = JLabel( "N cav. amp. backward steps multiplier =", JLabel.RIGHT) self.cav_amp_backward_steps_mult_text = DoubleInputTextField( 1.0, ScientificNumberFormat(2), 5) panel0.add(cav_amp_backward_steps_mult_label) panel0.add(self.cav_amp_backward_steps_mult_text) #---- cavity's wait time multiplier panel1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) cav_amp_wait_time_mult_label = JLabel( "Cav. amp. time wait multiplier =", JLabel.RIGHT) self.cav_amp_wait_time_mult_text = DoubleInputTextField( 3.0, ScientificNumberFormat(2), 5) panel1.add(cav_amp_wait_time_mult_label) panel1.add(self.cav_amp_wait_time_mult_text) #---- cavity's safe amplitude up and down limits panel2 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) safe_relative_amp_up_label = JLabel("Cav. amp. safe Up [%]=", JLabel.RIGHT) self.safe_relative_amp_up_text = DoubleInputTextField( 7.0, ScientificNumberFormat(2), 5) panel2.add(safe_relative_amp_up_label) panel2.add(self.safe_relative_amp_up_text) panel3 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) safe_relative_amp_down_label = JLabel("Cav. amp. safe Down [%]=", JLabel.RIGHT) self.safe_relative_amp_down_text = DoubleInputTextField( 7.0, ScientificNumberFormat(2), 5) panel3.add(safe_relative_amp_down_label) panel3.add(self.safe_relative_amp_down_text) #----- cavity's guess phase[deg] and amplitude[%] corrections after 360 deg full scan for inner BPMs panel4 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) guess_phase_shift_label = JLabel( "Cav. Guess Phase Shift after Full Scan [deg]=", JLabel.RIGHT) self.guess_phase_shift_text = DoubleInputTextField( 0.0, ScientificNumberFormat(2), 5) panel4.add(guess_phase_shift_label) panel4.add(self.guess_phase_shift_text) panel5 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) guess_cav_amp_shift_label = JLabel( "Cav. Amp Shift after Full Scan [%]=", JLabel.RIGHT) self.guess_cav_amp_shift_text = DoubleInputTextField( 0.0, ScientificNumberFormat(2), 5) panel5.add(guess_cav_amp_shift_label) panel5.add(self.guess_cav_amp_shift_text) #----------------------------------------------- params_panel = JPanel(GridLayout(6, 1, 1, 1)) params_panel.add(panel0) params_panel.add(panel1) params_panel.add(panel2) params_panel.add(panel3) params_panel.add(panel4) params_panel.add(panel5) #------------------------------------------------ self.parameters_panel.add(params_panel, BorderLayout.NORTH) #------------------------------------------------ self.scan_progress_bar = Scan_Progress_Bar(self.main_loop_controller, self) #------------------------------------------------ cav_wrapper.safe_relative_amp_up_text = self.safe_relative_amp_up_text cav_wrapper.safe_relative_amp_down_text = self.safe_relative_amp_down_text def getMainPanel(self): return self.main_panel def getParamsPanel(self): return self.parameters_panel def getScanProgressBarPanel(self): return self.scan_progress_bar.scan_progress_panel def getScanProgressBar(self): return self.scan_progress_bar def runSetUpAlgorithm(self): """ Returns (true, text) in the case of the success """ text = "Good. Cav=" + self.cav_wrapper.alias return (true, text) def init(self): """ reads the pv values """ self.cav_wrapper.init() self.scan_progress_bar.init() def writeDataToXML(self, root_da): """ Abstract method. This method should be implemented in the subclass """ cav_cntrl_data_da = root_da.createChild("CAVITY_CONTROLLER_" + self.cav_wrapper.alias) def readDataFromXML(self, cav_cntrl_data_da): """ Abstract method. This method should be implemented in the subclass """ pass def checkBPM_Usage(self, bpm_wrapper): """ Abstract method. Returns True or False about this controller usage of the BPM """ return false def timeSleep(self, time_sleep): n_parts = 5 tm = time_sleep / n_parts for ind in range(n_parts): time.sleep(tm) self.scan_progress_bar.count_and_update(tm) if (self.main_loop_controller.loop_run_state.shouldStop): return def setMaxTimeCount(self): """ Abstract method. It should be implemented in each subclass. It returns the maximal time count. """ print "Debug. Abstract_Cavity_Controller.setMaxTimeCount() This method should be implemented in a subclass." self.scan_progress_bar.setMaxTimeCount(100.) return self.scan_progress_bar.count_max def getPastaFittingTime(self): """ Abstract method. It should be implemented in each subclass. """ return 0. def initProgressBar(self): self.scan_progress_bar.init() def wrtiteAbstractCntrlToXML(self, root_da): abstr_cntrl_data_da = root_da.createChild( "ABSTRACT_CAVITY_CONTROLLER_PARAMS") abstr_cntrl_data_da.setValue( "amp_steps_mult", self.cav_amp_backward_steps_mult_text.getValue()) abstr_cntrl_data_da.setValue( "amp_time_mult", self.cav_amp_wait_time_mult_text.getValue()) abstr_cntrl_data_da.setValue("amp_safe_up_percent", self.safe_relative_amp_up_text.getValue()) abstr_cntrl_data_da.setValue( "amp_safe_down_percent", self.safe_relative_amp_down_text.getValue()) abstr_cntrl_data_da.setValue("guess_phase_shift", self.guess_phase_shift_text.getValue()) abstr_cntrl_data_da.setValue("guess_amp_shift_percent", self.guess_cav_amp_shift_text.getValue()) def readAbstractCntrlFromXML(self, root_da): abstr_cntrl_data_da = root_da.childAdaptor( "ABSTRACT_CAVITY_CONTROLLER_PARAMS") self.cav_amp_backward_steps_mult_text.setValue( abstr_cntrl_data_da.doubleValue("amp_steps_mult")) self.cav_amp_wait_time_mult_text.setValue( abstr_cntrl_data_da.doubleValue("amp_time_mult")) if (abstr_cntrl_data_da.hasAttribute("amp_safe_up_percent")): self.safe_relative_amp_up_text.setValue( abstr_cntrl_data_da.doubleValue("amp_safe_up_percent")) if (abstr_cntrl_data_da.hasAttribute("amp_safe_down_percent")): self.safe_relative_amp_down_text.setValue( abstr_cntrl_data_da.doubleValue("amp_safe_down_percent")) if (abstr_cntrl_data_da.hasAttribute("guess_phase_shift")): self.guess_phase_shift_text.setValue( abstr_cntrl_data_da.doubleValue("guess_phase_shift")) if (abstr_cntrl_data_da.hasAttribute("guess_amp_shift_percent")): self.guess_cav_amp_shift_text.setValue( abstr_cntrl_data_da.doubleValue("guess_amp_shift_percent"))
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder(etched_border,"BPMs Phase Offsets: start from HEBT1 backward") self.setBorder(titled_border) #--- stage 1 GUI elements stage1_lbl = JLabel("Stage 1.",JLabel.RIGHT) get_statistics_button = JButton("Start HEBT1 BPMs Satatistics") get_statistics_button.addActionListener(Get_HEBT_Statistics_Button_Listener(self.scl_long_tuneup_controller)) stop_statistics_button = JButton("Stop") stop_statistics_button.addActionListener(Stop_HEBT_Statistics_Button_Listener(self.scl_long_tuneup_controller)) iter_lbl = JLabel("Iterations=",JLabel.RIGHT) self.iter_text = DoubleInputTextField(10.0,DecimalFormat("##"),2) iter_left_lbl = JLabel("Count=",JLabel.RIGHT) self.iter_left_text = DoubleInputTextField(0.0,DecimalFormat("##"),2) ring_energy_lbl = JLabel("<html>E<SUB>RING</SUB>[MeV]= <html>",JLabel.RIGHT) self.ring_energy_text = DoubleInputTextField(0.0,DecimalFormat("####.###"),8) ring_energy_err_lbl = JLabel(" +- ",JLabel.RIGHT) self.ring_energy_err_text = DoubleInputTextField(0.0,DecimalFormat("####.###"),8) panel_1_1 = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) panel_1_1.setBorder(etched_border) panel_1_1.add(get_statistics_button) panel_1_1.add(stop_statistics_button) panel_1_1.add(iter_lbl) panel_1_1.add(self.iter_text) panel_1_1.add(iter_left_lbl) panel_1_1.add(self.iter_left_text) panel_1_1.add(ring_energy_lbl) panel_1_1.add(self.ring_energy_text) panel_1_1.add(ring_energy_err_lbl) panel_1_1.add(self.ring_energy_err_text) get_em_phase_offsets_button = JButton("Get BPM Offsets from Energy Meter") get_em_phase_offsets_button.addActionListener(Get_Energy_Meter_Offsets_Button_Listener(self.scl_long_tuneup_controller)) panel_1_2 = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) panel_1_2.setBorder(etched_border) panel_1_2.add(get_em_phase_offsets_button) #--- stage 2 GUI elements stage2_lbl = JLabel("Stage 2.",JLabel.RIGHT) get_offsets_hebt1_button = JButton("Calculate Offsets from HEBT1 backward") get_offsets_hebt1_button.addActionListener(Offsets_from_HEBT1_Button_Listener(self.scl_long_tuneup_controller)) init_energy_lbl = JLabel("<html> SCL Entrance E<SUB>kin</SUB>[MeV] = <html>",JLabel.RIGHT) self.init_energy_text = DoubleInputTextField(0.,DecimalFormat("###.###"),8) #------ Stage 1 Panel stage1_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) stage1_panel.setBorder(etched_border) stage1_panel.add(stage1_lbl) stage1_panel.add(panel_1_1) stage1_panel.add(panel_1_2) #------ Stage 2 Panel stage2_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) stage2_panel.setBorder(etched_border) stage2_panel.add(stage2_lbl) stage2_panel.add(get_offsets_hebt1_button) stage2_panel.add(init_energy_lbl) stage2_panel.add(self.init_energy_text) #-------------------------------------------- self.add(stage1_panel,BorderLayout.NORTH) self.add(stage2_panel,BorderLayout.SOUTH) #------ Statistic run controller self.statistic_state_controller = StatisticStateController()
def __init__(self, event_monitor_document): self.event_monitor_document = event_monitor_document self.main_panel = JPanel(BorderLayout()) etched_border = BorderFactory.createEtchedBorder() #etched_border = BorderFactory.createRaisedSoftBevelBorder() etched_border = BorderFactory.createLineBorder(Color.black, 2, false) #-------------------------------------------------------------- self.left_panel = JPanel(VerticalLayout()) main_label = JLabel( "============ Event Monitor Parameters =============", JLabel.CENTER) self.left_panel.add(main_label) self.left_panel.setBorder(etched_border) #----------Event Monotor Params------------- monitor_params0_panel = JPanel(GridLayout(4, 2)) self.buffer_size_text = buffer_size_text buffer_size_label = JLabel("Buff. Time [sec]:", JLabel.RIGHT) monitor_params0_panel.add(buffer_size_label) monitor_params0_panel.add(self.buffer_size_text) self.event_buffer_size_text = DoubleInputTextField( 3.0, ScientificNumberFormat(1), 10) event_buffer_size_label = JLabel("Event Buff. Size:", JLabel.RIGHT) monitor_params0_panel.add(event_buffer_size_label) monitor_params0_panel.add(self.event_buffer_size_text) self.min_limit_text = DoubleInputTextField(1.0e-8, ScientificNumberFormat(4), 10) self.max_limit_text = DoubleInputTextField(1.0e-3, ScientificNumberFormat(4), 10) min_lim_label = JLabel("Trigger Min Value:", JLabel.RIGHT) max_lim_label = JLabel("Trigger Max Value:", JLabel.RIGHT) monitor_params0_panel.add(min_lim_label) monitor_params0_panel.add(self.min_limit_text) monitor_params0_panel.add(max_lim_label) monitor_params0_panel.add(self.max_limit_text) monitor_params1_panel = JPanel(BorderLayout()) monitor_params1_panel.add(monitor_params0_panel, BorderLayout.WEST) monitor_params_panel = JPanel(BorderLayout()) monitor_params_panel.add(monitor_params1_panel, BorderLayout.NORTH) self.left_panel.add(monitor_params_panel) self.pvTriggerJText = JTextField(ChannelNameDocument(), "", 30) pvTriggerButton = JButton("Set Trigger PV") pvTriggerButton.addActionListener(Set_Trigger_PV_Listener(self)) triggerPanel = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) triggerPanel.add(pvTriggerButton) triggerPanel.add(self.pvTriggerJText) self.left_panel.add(triggerPanel) self.pvMonitorNameJText = JTextField(ChannelNameDocument(), "", 30) #------------Two Tables Panel -------------------- twoTables_panel = JPanel(GridLayout(2, 1)) #------------Monitored PV table------------------- pvMonitored_panel = JPanel(BorderLayout()) border = BorderFactory.createTitledBorder(etched_border, "Monitored PVs") pvMonitored_panel.setBorder(border) self.pvMonitorJText = JTextField(ChannelNameDocument(), "", 25) pvMonitorButton = JButton("Add PV to Monitored") pvMonitorRemoveButton = JButton("Remove Selected PVs") pvMonitorButton.addActionListener(Add_PV_To_Monitored_Listener(self)) pvMonitorRemoveButton.addActionListener( Remove_Monitored_PVs_Listener(self)) pvMonitoredPanel0 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) pvMonitoredPanel0.add(pvMonitorButton) pvMonitoredPanel0.add(self.pvMonitorJText) pvMonitoredPanel1 = JPanel(FlowLayout(FlowLayout.RIGHT, 1, 1)) pvMonitoredPanel1.add(pvMonitorRemoveButton) pvMonitoredPanel2 = JPanel(BorderLayout()) pvMonitoredPanel2.add(pvMonitoredPanel0, BorderLayout.NORTH) pvMonitoredPanel2.add(pvMonitoredPanel1, BorderLayout.SOUTH) pvMonitored_panel.add(pvMonitoredPanel2, BorderLayout.NORTH) self.pv_monitored_table = JTable(Monitored_PV_Table_Model(self)) self.pv_monitored_table.setPreferredScrollableViewportSize( Dimension(200, 160)) #self.pv_monitored_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.pv_monitored_table.setFillsViewportHeight(true) pvMonitored_panel.add(JScrollPane(self.pv_monitored_table), BorderLayout.CENTER) twoTables_panel.add(pvMonitored_panel) #------------Event Buffer Table------------------- buffEvents_panel = JPanel(BorderLayout()) border = BorderFactory.createTitledBorder(etched_border, "Buffered Events") buffEvents_panel.setBorder(border) self.events_table = JTable(Buffer_Events_Table_Model(self)) self.events_table.setPreferredScrollableViewportSize( Dimension(200, 160)) self.events_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.events_table.setFillsViewportHeight(true) buffEvents_panel.add(JScrollPane(self.events_table), BorderLayout.CENTER) twoTables_panel.add(buffEvents_panel) #------Stop - Start Monitoring Buttons startStopPanel = JPanel(BorderLayout()) startStopPanel.setBorder(etched_border) self.startMonitoringButton = JButton("Start Monitoring") self.stopMonitoringButton = JButton("Stop Monitoring") self.startMonitoringButton.addActionListener( Start_Monitoring_Listener(self)) self.stopMonitoringButton.addActionListener( Stop_Monitoring_Listener(self)) startStopButtonsPanel = JPanel(FlowLayout(FlowLayout.LEFT, 5, 5)) startStopButtonsPanel.add(self.startMonitoringButton) startStopButtonsPanel.add(self.stopMonitoringButton) startStopPanel.add(startStopButtonsPanel, BorderLayout.NORTH) self.sinceTimeJText = JTextField(30) self.sinceTimeJText.setForeground(Color.red) self.sinceTimeJText.setText("Not Running.") startStopPanel.add(self.sinceTimeJText, BorderLayout.SOUTH) #-------Event Handlers-------------------------------- self.event_holder = Event_Object_Holder(self.event_buffer_size_text, self) self.event_handler = Event_Handler(self.event_holder, self.min_limit_text, self.max_limit_text) #-----graph panels-------------------- self.graphs_panel = TwoGraphsPanel(self) #-----setup dump directory ----------- self.dump_directory_panel = JPanel(BorderLayout()) self.dump_button = JRadioButton("Dump Events to Files") self.dump_button.addActionListener(Dump_Events_To_Files_Listener(self)) dump_dir_choose_button = JButton(" Choose Dump Dir. ") dump_dir_choose_button.addActionListener(Find_Dump_Dir_Listener(self)) dump_dir_label = JLabel(" Dump Dir:", JLabel.RIGHT) self.dumpDirJText = JTextField(50) self.dumpDirJText.setText("/ade/xal/docs/EventMonitor/EventDirs/") dump_dir_panel0 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) dump_dir_panel0.add(self.dump_button) dump_dir_panel1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) dump_dir_panel1.add(dump_dir_choose_button) dump_dir_panel1.add(dump_dir_label) dump_dir_panel2 = JPanel(BorderLayout()) dump_dir_panel2.add(dump_dir_panel1, BorderLayout.WEST) dump_dir_panel2.add(self.dumpDirJText, BorderLayout.CENTER) self.dump_directory_panel.add(dump_dir_panel0, BorderLayout.NORTH) self.dump_directory_panel.add(dump_dir_panel2, BorderLayout.SOUTH) #-----set up listeners ------------------------------------ tables_selection_listener = Table_Selection_Listener(self) self.pv_monitored_table.getSelectionModel().addListSelectionListener( tables_selection_listener) self.events_table.getSelectionModel().addListSelectionListener( tables_selection_listener) #--------- set up main panel params_and_tables_panel = JPanel(BorderLayout()) params_and_tables_panel.add(self.left_panel, BorderLayout.NORTH) params_and_tables_panel.add(twoTables_panel, BorderLayout.CENTER) params_and_tables_panel.add(startStopPanel, BorderLayout.SOUTH) self.main_panel.add(params_and_tables_panel, BorderLayout.WEST) self.main_panel.add(self.graphs_panel.getMainPanel(), BorderLayout.CENTER) self.main_panel.add(self.dump_directory_panel, BorderLayout.SOUTH)
def __init__(self,scl_long_tuneup_controller): #--- scl_long_tuneup_controller the parent document for all SCL tune up controllers self.scl_long_tuneup_controller = scl_long_tuneup_controller self.main_panel = JPanel(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() #------top init panel----------------------- top_init_panel = JPanel(BorderLayout()) init_panel = JPanel(BorderLayout()) init_panel0 = JPanel(BorderLayout()) init_button = JButton(" Init BPMs and Cavities ") get_quad_fields_button = JButton(" Get Quad Fields ") restore_init_button = JButton(" Restore Cavities' Phases ") set_unblanked_button = JButton("Un-blank all Cavities") init_button.addActionListener(Init_BPMs_and_Cavities_Button_Listener(self.scl_long_tuneup_controller)) get_quad_fields_button.addActionListener(Get_Quad_Fields_Button_Listener(self.scl_long_tuneup_controller)) restore_init_button.addActionListener(Restore_Init_BPMs_and_Cavities_Button_Listener(self.scl_long_tuneup_controller)) set_unblanked_button.addActionListener(Unblank_All_Cavities_Button_Listener(self.scl_long_tuneup_controller)) expl_text = "Checks response from BPMs and memorizes initial amp./phases of cavities. \n" expl_text = expl_text + " D - Design, I.L. - Initial Live values. \n" expl_text = expl_text + " BPM1 and BPM2 will be used for the cavity phase setup during the raw phase scan.\n" init_text = JTextArea(expl_text) init_panel01 = JPanel(GridLayout(4,1,10,10)) init_panel01.add(init_button) init_panel01.add(get_quad_fields_button) init_panel01.add(restore_init_button) init_panel01.add(set_unblanked_button) init_panel01.setBorder(etched_border) init_panel0.add(init_panel01,BorderLayout.WEST) init_panel0.add(init_text,BorderLayout.CENTER) init_panel1 = JPanel(FlowLayout(FlowLayout.LEFT,5,5)) init_set_bpm1_button = JButton(" Set BPM1 to Selected Cavs ") init_set_bpm2_button = JButton(" Set BPM2 to Selected Cavs ") init_set_bpm3_button = JButton(" Clear BPM1/BPM2 for Selected Cavs ") init_set_bpm1_button.addActionListener(Init_Set_BPM_to_Cav_Button_Listener(self.scl_long_tuneup_controller,1)) init_set_bpm2_button.addActionListener(Init_Set_BPM_to_Cav_Button_Listener(self.scl_long_tuneup_controller,2)) init_set_bpm3_button.addActionListener(Clear_BPM0_BPM1_Button_Listener(self.scl_long_tuneup_controller)) min_bpm_dist_label = JLabel("Min. BPM 1-2 Dist.[m]=",JLabel.RIGHT) self.min_bpm_dist_txt = DoubleInputTextField(22.0,ScientificNumberFormat(6),6) max_bpm_dist_label = JLabel("Max.=",JLabel.RIGHT) self.max_bpm_dist_txt = DoubleInputTextField(75.0,ScientificNumberFormat(6),6) init_panel1.add(init_set_bpm1_button) init_panel1.add(init_set_bpm2_button) init_panel1.add(init_set_bpm3_button) init_panel1.add(min_bpm_dist_label) init_panel1.add(self.min_bpm_dist_txt) init_panel1.add(max_bpm_dist_label) init_panel1.add(self.max_bpm_dist_txt) init_panel.add(init_panel0,BorderLayout.SOUTH) init_panel.add(init_panel1,BorderLayout.NORTH) init_panel.setBorder(etched_border) top_init_panel.add(init_panel,BorderLayout.NORTH) self.bpm_table = JTable(Init_BPMs_Table_Model(self.scl_long_tuneup_controller)) self.cav_table = JTable(Init_Cavities_Table_Model(self.scl_long_tuneup_controller)) self.bpm_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.cav_table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION) self.bpm_table.setFillsViewportHeight(true) self.cav_table.setFillsViewportHeight(true) self.bpm_table.setPreferredScrollableViewportSize(Dimension(300,300)) #self.cav_table.setPreferredScrollableViewportSize(Dimension(120,300)) scrl_panel0 = JScrollPane(self.bpm_table) scrl_panel1 = JScrollPane(self.cav_table) scrl_panel0.setBorder(etched_border) scrl_panel1.setBorder(etched_border) bpm_cav_tables_panel = JPanel(BorderLayout()) bpm_cav_tables_panel.add(scrl_panel0,BorderLayout.WEST) bpm_cav_tables_panel.add(scrl_panel1,BorderLayout.CENTER) top_init_panel.add(bpm_cav_tables_panel,BorderLayout.CENTER) #-------------------------------------------------- self.main_panel.add(top_init_panel,BorderLayout.CENTER) #-------------------------------------------------- self.scl_quad_fields_dict_holder = SCL_Quad_Fields_Dict_Holder(self.scl_long_tuneup_controller)
class SCL_Scan_Data_CleanUp_Controller: def __init__(self, scl_long_tuneup_controller): #--- scl_long_tuneup_controller the parent document for all SCL tune up controllers self.scl_long_tuneup_controller = scl_long_tuneup_controller #----etched border etched_border = BorderFactory.createEtchedBorder() #----main panel self.main_panel = JPanel(BorderLayout()) #------top params panel----------------------- right_info_panel = JPanel(BorderLayout()) right_top_control_panel = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) analysis_button = JButton("Find BAD Points") analysis_button.addActionListener(Analyze_Data_Button_Listener(self)) right_top_control_panel.add(analysis_button) #------ maximal bpm phase error after the scan max_phase_err_lbl = JLabel("Max BPM Phase Err = ", JLabel.RIGHT) self.max_phase_err_text = DoubleInputTextField(10.0, DecimalFormat("##.#"), 5) right_top_control_panel.add(max_phase_err_lbl) right_top_control_panel.add(self.max_phase_err_text) #----------------------------------------------- right_bottom_control_panel = JPanel(BorderLayout()) right_bottom_control_panel0 = JPanel(BorderLayout()) right_bottom_control_panel1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) right_bottom_control_panel.add(right_bottom_control_panel0, BorderLayout.NORTH) right_bottom_control_panel.add(right_bottom_control_panel1, BorderLayout.SOUTH) statistics_of_errors_lbl = JLabel("Statistics:", JLabel.RIGHT) self.statistics_of_errors_txt = JTextField() right_bottom_control_panel0.add(statistics_of_errors_lbl, BorderLayout.WEST) right_bottom_control_panel0.add(self.statistics_of_errors_txt, BorderLayout.CENTER) remove_worst_points_button = JButton("Remove Worst Points") remove_worst_points_button.addActionListener( CleanUp_Worst_Phase_Points_Data_Button_Listener(self)) remove_all_bad_bpms_button = JButton("Remove All Bad BPMs") remove_all_bad_bpms_button.addActionListener( CleanUp_All_Bad_BPMs_Button_Listener(self)) right_bottom_control_panel1.add(remove_worst_points_button) right_bottom_control_panel1.add(remove_all_bad_bpms_button) #----------------------------------------------- right_tables_panel = JPanel(GridLayout(1, 3)) right_info_panel.add(right_top_control_panel, BorderLayout.NORTH) right_info_panel.add(right_tables_panel, BorderLayout.CENTER) right_info_panel.add(right_bottom_control_panel, BorderLayout.SOUTH) self.main_panel.add(right_info_panel, BorderLayout.EAST) #------cavities scan table panel -------- self.bad_bpms_amp_phase_graphs_panel = Bad_BPMs_Amp_Phase_Graphs_Panel( self) self.main_panel.add(self.bad_bpms_amp_phase_graphs_panel, BorderLayout.CENTER) #------ let's make tables for a list of cavities, bpms, and bad points indexes self.cavs_with_bad_data_table_model = Cavs_with_Bad_PhaseScan_Table_Model( self) self.cavs_table = JTable(self.cavs_with_bad_data_table_model) self.cavs_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.cavs_table.setFillsViewportHeight(true) self.cavs_table.setPreferredScrollableViewportSize(Dimension(180, 300)) self.cavs_table.getSelectionModel().addListSelectionListener( Cavs_Table_Selection_Listener(self)) self.bpms_table_model = Bad_PhaseScan_BPMs_Table_Model(self) self.bpms_table = JTable(self.bpms_table_model) self.bpms_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.bpms_table.setFillsViewportHeight(true) self.bpms_table.getSelectionModel().addListSelectionListener( BPMs_Table_Selection_Listener(self)) self.bpms_table.setPreferredScrollableViewportSize(Dimension(180, 300)) self.points_table_model = Bad_Points_Table_Model(self) self.points_table = JTable(self.points_table_model) self.points_table.setFillsViewportHeight(true) self.points_table.setPreferredScrollableViewportSize( Dimension(180, 300)) #----- set scroll panes scrl_panel0 = JScrollPane(self.cavs_table) scrl_panel1 = JScrollPane(self.bpms_table) scrl_panel2 = JScrollPane(self.points_table) scrl_panel0.setBorder( BorderFactory.createTitledBorder(etched_border, "Cavs")) scrl_panel1.setBorder( BorderFactory.createTitledBorder(etched_border, "BPMs")) scrl_panel2.setBorder( BorderFactory.createTitledBorder(etched_border, "Bad Points")) right_tables_panel.setBorder(etched_border) right_tables_panel.add(scrl_panel0) right_tables_panel.add(scrl_panel1) right_tables_panel.add(scrl_panel2) #----- dictionary with the bad data self.cavs_to_bpm_dict[cav_wrapper] = [bpm_wrappers,bpms_to_points_dict] self.cavs_to_bpm_dict = {} #----- arrays with bad data for the tables self.cavs_with_bad_data_arr = [] self.bpms_arr = [] self.points_arr = [] def cleanUp_All_Bad_BPMs_Method(self): scl_long_tuneup_controller = self.scl_long_tuneup_controller cav_wrappers = scl_long_tuneup_controller.cav_wrappers[1:] #----- dictionary with the bad data cavs_to_bpm_dict = self.cavs_to_bpm_dict #----- let's go through all cavities to find the bad bpms for cav_wrapper in cav_wrappers: if (cav_wrapper.isGood and cav_wrapper.isMeasured): if (cavs_to_bpm_dict.has_key(cav_wrapper)): [bpm_wrappers, bpms_to_points_dict] = cavs_to_bpm_dict[cav_wrapper] for bpm_wrapper_bad in bpm_wrappers: for bpm_ind in range(len(cav_wrapper.bpm_wrappers)): bpm_wrapper = cav_wrapper.bpm_wrappers[bpm_ind] if (bpm_wrapper_bad == bpm_wrapper): cav_wrapper.bpm_wrappers_useInAmpBPMs[ bpm_ind] = false cav_wrapper.bpm_wrappers_useInPhaseAnalysis[ bpm_ind] = false def cleanUp_Worst_Phase_Points_Data_Method(self): scl_long_tuneup_controller = self.scl_long_tuneup_controller cav_wrappers = scl_long_tuneup_controller.cav_wrappers[1:] #----- dictionary with the bad data cavs_to_bpm_dict = self.cavs_to_bpm_dict #----- let's go through all cavities to find the worst phase scan points #----- worst points means maximal number of bad bpms with it n_total_removed_points = 0 for cav_wrapper in cav_wrappers: if (cav_wrapper.isGood and cav_wrapper.isMeasured): if (cavs_to_bpm_dict.has_key(cav_wrapper)): [bpm_wrappers, bpms_to_points_dict] = cavs_to_bpm_dict[cav_wrapper] #----- numb_of_points_dict[point_scan_ind] = [bpm1,...] numb_of_points_dict = {} for bpm_wrapper in bpm_wrappers: bad_points_arr = bpms_to_points_dict[bpm_wrapper] for [ind, x, y] in bad_points_arr: if (numb_of_points_dict.has_key(ind)): numb_of_points_dict[ind].append(bpm_wrapper) else: numb_of_points_dict[ind] = [ bpm_wrapper, ] max_bpms_ind = -1 max_numb_of_bpms = 0 for ind in numb_of_points_dict.keys(): n_bpms = len(numb_of_points_dict[ind]) if (n_bpms > max_numb_of_bpms): max_bpms_ind = ind if (max_bpms_ind >= 0): #---- the phase scan data with this index should be removed n_bpms = len(numb_of_points_dict[max_bpms_ind]) if (n_bpms > 1): n_total_removed_points += n_bpms gd = cav_wrapper.phaseDiffPlot gd.removePoint(max_bpms_ind) for bpm_wrapper in cav_wrapper.bpm_wrappers: (graphDataAmp, graphDataPhase ) = cav_wrapper.getAmpPhaseGraphs(bpm_wrapper) if (graphDataAmp != null): graphDataAmp.removePoint(max_bpms_ind) if (graphDataPhase != null): graphDataPhase.removePoint(max_bpms_ind) #print "debug cav=",cav_wrapper.alias," n bpms=",n_bpms #print "debug n_total_removed_points=",n_total_removed_points def analyze_Data_Method(self): scl_long_tuneup_controller = self.scl_long_tuneup_controller max_phase_diff0 = self.max_phase_err_text.getValue() cav_wrappers = scl_long_tuneup_controller.cav_wrappers[1:] #----- dictionary with the bad data self.cavs_to_bpm_dict = {} cavs_to_bpm_dict = self.cavs_to_bpm_dict #----- arrays with bad data for the tables self.cavs_with_bad_data_arr = [] self.bpms_arr = [] self.points_arr = [] #---- data analysis for bad points total_nPoints = 0 for cav_wrapper in cav_wrappers: if (cav_wrapper.isGood and cav_wrapper.isMeasured): bpm_wrapper0 = cav_wrapper.bpm_wrapper0 bpm_wrapper1 = cav_wrapper.bpm_wrapper1 pos0 = bpm_wrapper0.pos pos1 = bpm_wrapper1.pos phaseDiffPlot = cav_wrapper.phaseDiffPlot (graphDataAmp0, graphDataPhase0 ) = cav_wrapper.bpm_amp_phase_dict[bpm_wrapper0] if (phaseDiffPlot.getNumbOfPoints() == 0): continue for bpm_wrapper_ind in range(len(cav_wrapper.bpm_wrappers)): bpm_wrapper = cav_wrapper.bpm_wrappers[bpm_wrapper_ind] pos = bpm_wrapper.pos if (pos < pos0): continue pos_coeff = (pos - pos0) / (pos1 - pos0) max_phase_diff = max_phase_diff0 if (pos_coeff >= 1.0): max_phase_diff = pos_coeff * max_phase_diff0 if (cav_wrapper. bpm_wrappers_useInPhaseAnalysis[bpm_wrapper_ind]): (graphDataAmp, graphDataPhase ) = cav_wrapper.bpm_amp_phase_dict[bpm_wrapper] nPoints = phaseDiffPlot.getNumbOfPoints() bpm_phase_delta = graphDataPhase.getY( nPoints - 1) - graphDataPhase0.getY( nPoints - 1 ) - pos_coeff * phaseDiffPlot.getY(nPoints - 1) bad_points_arr = [] for ind in range(phaseDiffPlot.getNumbOfPoints()): total_nPoints += 1 y = graphDataPhase.getY( ind) - graphDataPhase0.getY( ind) - pos_coeff * phaseDiffPlot.getY( ind) - bpm_phase_delta y = makePhaseNear(y, 0.) if (abs(y) > max_phase_diff): bad_points_arr.append( [ind, graphDataPhase.getX(ind), y]) if (len(bad_points_arr) > 0): if (not cavs_to_bpm_dict.has_key(cav_wrapper)): cavs_to_bpm_dict[cav_wrapper] = [[], {}] [bpm_wrappers, bpms_to_points_dict ] = cavs_to_bpm_dict[cav_wrapper] bpm_wrappers.append(bpm_wrapper) bpms_to_points_dict[bpm_wrapper] = bad_points_arr for cav_wrapper in cav_wrappers: if (cavs_to_bpm_dict.has_key(cav_wrapper)): self.cavs_with_bad_data_arr.append(cav_wrapper) #-------------------------------------------------------------------- nCavs = 0 nBPMs = 0 nPoints = 0 for cav_wrapper in self.cavs_with_bad_data_arr: [bpm_wrappers, bpms_to_points_dict] = cavs_to_bpm_dict[cav_wrapper] nCavs += 1 nBPMs += len(bpm_wrappers) for bpm_wrapper in bpm_wrappers: points_arr = bpms_to_points_dict[bpm_wrapper] nPoints += len(points_arr) st = "N Bad: Cavs= " + str(nCavs) + " BPMs= " + str( nBPMs) + " Phase Points=" + str(nPoints) + "/" + str( total_nPoints) self.statistics_of_errors_txt.setText(st) self.cavs_table.getModel().fireTableDataChanged() self.bpms_table.getModel().fireTableDataChanged() self.points_table.getModel().fireTableDataChanged() nCavs = len(self.cavs_with_bad_data_arr)