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,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,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,ScientificNumberFormat(2),4) time_step_label = JLabel("Time Step[sec]=",JLabel.RIGHT) self.time_step_text = DoubleInputTextField(1.1,ScientificNumberFormat(3),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): 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)
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.,ScientificNumberFormat(1),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.,ScientificNumberFormat(5),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,ScientificNumberFormat(7),6) self.add(get_offsets_ccl1_button) self.add(ccl4_energy_lbl) self.add(self.ccl4_energy_text)
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 __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("<html>Copy Old (A<SUB>EPICS</SUB>,Δφ<SUB>RF</SUB>)->New (A<SUB>EPICS</SUB>,Δ&phi<SUB>RF</SUB>;)<html>") copy_old_button.addActionListener(Copy_Old_to_New_Listener(self.scl_long_tuneup_controller)) change_selected_lbl = JLabel("<html>Change Selected New Δφ<SUB>RF</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) buttons_panel.add(change_selected_lbl) buttons_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.,ScientificNumberFormat(7),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.SOUTH) #---- this is a holder for RF_Gap_Phases_Holder_for_Table_Selection self.rf_gap_phases_holder = null
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, 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)
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)
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,ScientificNumberFormat(1),2) iter_left_lbl = JLabel("Count=",JLabel.RIGHT) self.iter_left_text = DoubleInputTextField(0.0,ScientificNumberFormat(1),2) ring_energy_lbl = JLabel("<html>E<SUB>RING</SUB>[MeV]= <html>",JLabel.RIGHT) self.ring_energy_text = DoubleInputTextField(0.0,ScientificNumberFormat(7),8) ring_energy_err_lbl = JLabel(" +- ",JLabel.RIGHT) self.ring_energy_err_text = DoubleInputTextField(0.0,ScientificNumberFormat(4),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.,ScientificNumberFormat(7),6) #------ 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)
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