Exemple #1
0
 def saveDocumentAs(self, url):
     # here you save of the application to the XML file
     da = XmlDataAdaptor.newEmptyDocumentAdaptor()
     root_da = da.createChild("Warm_Linac_SetUp")
     self.warm_linac_rf_setup_document.main_loop_controller.writeDataToXML(
         root_da)
     da.writeToUrl(url)
Exemple #2
0
	def writeData(self, url):
		da = XmlDataAdaptor.newEmptyDocumentAdaptor()
		root_da = da.createChild("LINAC_Wizard")
		root_da.setValue("Title", url.getFile())
		root_da.setValue("AccSequence", self.getSeqNames())
		#---- write WS or LW data records --------
		self.writeData_WS_LW_Records(root_da)
		#---- write Initial Twiss and beam parameters --------
		self.writeTransverseTwiss(root_da)
		#---- write SCL Phase Scan data
		self.linac_wizard_document.scl_long_tuneup_controller.writeDataToXML(root_da)
		#---- dump data into the file ------------
		da.writeToUrl(url)
	def writeData(self, url):
		da = XmlDataAdaptor.newEmptyDocumentAdaptor()
		root_da = da.createChild("LINAC_Wizard")
		root_da.setValue("Title", url.getFile())
		root_da.setValue("AccSequence", self.getSeqNames())
		#---- write WS or LW data records --------
		self.writeData_WS_LW_Records(root_da)
		#---- write Initial Twiss and beam parameters --------
		self.writeTransverseTwiss(root_da)
		#---- write SCL Phase Scan data
		self.linac_wizard_document.scl_long_tuneup_controller.writeDataToXML(root_da)
		#---- dump data into the file ------------
		da.writeToUrl(url)
	def actionPerformed(self,actionEvent):
		self.scl_long_tuneup_controller.getMessageTextField().setText("")	
		rightNow = Calendar.getInstance()
		date_format = SimpleDateFormat("MM.dd.yyyy")
		time_str = date_format.format(rightNow.getTime())				
		fc = JFileChooser(constants_lib.const_path_dict["XAL_XML_ACC_FILES_DIRS_PATH"])
		fc.setDialogTitle("Save SCL data into the SCL_new.xdxf file")
		fc.setApproveButtonText("Save")
		fl_filter = FileNameExtensionFilter("SCL Acc File",["xdxf",])
		fc.setFileFilter(fl_filter)
		fc.setSelectedFile(File("SCL_"+time_str+".xdxf"))		
		returnVal = fc.showOpenDialog(self.scl_long_tuneup_controller.linac_wizard_document.linac_wizard_window.frame)
		if(returnVal == JFileChooser.APPROVE_OPTION):
			fl_out = fc.getSelectedFile()
			fl_path = fl_out.getPath()
			if(fl_path.rfind(".xdxf") != (len(fl_path) - 5)):
				fl_out = File(fl_out.getPath()+".xdxf")	
			#---------prepare the XmlDataAdaptor 
			root_DA = XmlDataAdaptor.newEmptyDocumentAdaptor()
			scl_DA = root_DA.createChild("xdxf")	
			scl_DA.setValue("date",time_str)
			scl_DA.setValue("system","sns")
			scl_DA.setValue("version","2.0")
			#---- SCLMed	
			seq_name_arr = ["SCLMed","SCLHigh","HEBT1"]
			for seq_name in seq_name_arr:
				accl = self.scl_long_tuneup_controller.linac_wizard_document.accl
				seq = accl.findSequence(seq_name)
				cavs = seq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(SCLCavity.s_strType)))
				quads = seq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(Quadrupole.s_strType)))
				scl_seq_DA = scl_DA.createChild("sequence")
				scl_seq_DA.setValue("id",seq.getId())
				for quad in quads:
					node_DA = scl_seq_DA.createChild("node")
					node_DA.setValue("id",quad.getId())
					attr_DA = node_DA.createChild("attributes")
					field_DA = attr_DA.createChild("magnet")
					scl_quad_fields_dict_holder = self.scl_long_tuneup_controller.scl_long_tuneup_init_controller.scl_quad_fields_dict_holder
					field_DA.setValue("dfltMagFld",str(scl_quad_fields_dict_holder.quad_field_dict[quad]))
				for cav in cavs:
					node_DA = scl_seq_DA.createChild("sequence")
					node_DA.setValue("id",cav.getId())
					attr_DA = node_DA.createChild("attributes")
					rf_cav_DA = attr_DA.createChild("rfcavity")
					cav_wrappper = self.scl_long_tuneup_controller.getCav_WrapperForCavId(cav.getId())
					(amp,phase) =  (cav_wrappper.designAmp,cav_wrappper.designPhase)
					rf_cav_DA.setValue("amp",float("%8.5f"%amp))
					rf_cav_DA.setValue("phase",float("%8.3f"%phase))
			root_DA.writeTo(fl_out)		
Exemple #5
0
	def writeData(self, url):
		monitor_controller = self.event_monitor_document.monitor_controller
		da = XmlDataAdaptor.newEmptyDocumentAdaptor()
		root_da = da.createChild("Event_Monitor")
		root_da.setValue("buff_size_time", monitor_controller.buffer_size_text.getValue())
		root_da.setValue("event_buff_size", monitor_controller.event_buffer_size_text.getValue())
		root_da.setValue("min_limit", monitor_controller.min_limit_text.getValue())		
		root_da.setValue("max_limit", monitor_controller.max_limit_text.getValue())		
		root_da.setValue("triggerPV", monitor_controller.pvTriggerJText.getText())	
		root_da.setValue("eventDir", monitor_controller.dumpDirJText.getText())	
		event_handler = monitor_controller.event_handler
		pv_monitors = monitor_controller.event_handler.pv_monitors[:]
		for pv_monitor in pv_monitors:
			pv_name = pv_monitor.getPV_Name()
			pv_da = root_da.createChild("monitored_pv")
			pv_da.setValue("pv_name",pv_name)
		#---- dump data into the file ------------
		da.writeToUrl(url)
		self.filePathJText.setText(url.getFile())
	def saveDocumentAs(	self,url):
		# here you save of the application to the XML file 
		da = XmlDataAdaptor.newEmptyDocumentAdaptor()
		root_da = da.createChild("Warm_Linac_SetUp")	
		self.warm_linac_rf_setup_document.main_loop_controller.writeDataToXML(root_da)
		da.writeToUrl(url)
Exemple #7
0
                                        'RF:Cav0' + cav_id + ':Rg' + gap_id)
        else:
            new_name = new_name.replace('Rg' + gap_id,
                                        'RF:Cav0' + cav_id + ':Rg0' + gap_id)
        n_arr[n_arr.index(name)] = new_name
    elif name.startswith('SCL'):
        new_name = name.replace('SCL', 'SCL_RF')
        gap_id = new_name[-1]
        new_name = new_name.replace('Rg' + gap_id, 'Rg0' + gap_id)
        n_arr[n_arr.index(name)] = new_name
    else:
        pass

daptDoc = XmlDataAdaptor.adaptorForUrl(file_url, False)

daptWrite = XmlDataAdaptor.newEmptyDocumentAdaptor()

daptLinac = daptDoc.childAdaptor("xdxf")

lstDaptSeq = daptLinac.childAdaptors("sequence")

primseq = []
subseq = []
nodes = []
box = dict()
box2 = dict()

# START1-------------------------------------
for seq in lstDaptSeq:  # go through all of the sequences in the list of primary sequences
    seqid = seq.stringValue('id')
    if wanted(seqid):  # check if we are interested in this sequence