# Macros to create fio (Spectra Hamburg) files during a scan # # hp_fio.mac # # hp 11.07.2000 # hp 01.08.2000 changed some filenames, in the moment accesses /export/home/hupfeld/ssh/scp for copying # hp 14.08.2000 long headings are truncated, files remaining open will be closed at beginning of next scan # # # # This file redefines the normally empty user macros for scans # use new_fio_filename to initialize variables # if FIO_NAME is defined a fio-file will be created during each scan # if FIO_COPY is defined data will be copied with ssh to a remote computer # # # # global definitions # global FIO_NAME,FIO_NUMBER,FIO_FILE,FIO_COPY # # example values: # # FIO_NAME = "test_" # FIO_NUMBER = 0 # FIO_FILE = "test_1.fio" # FIO_COPY = sprintf("hupfeld@bajor.mu.aps.anl.gov:%c.trashcan/%c",34,34) # # # # ################################################################################# # # fio_show_settings # # hp 13.07.2000 # # displays the actual status of the fio macros # ################################################################################ # def fio_show_settings ' { printf("\nfio_show_settings (hp) 13.07.2000\n\n") if (FIO_NAME != "") { printf("Automatic creation of fio files during scans is on.\n") printf("The next scan will create the fio file %s%u.fio\n",FIO_NAME,FIO_NUMBER+1) printf("To stop the automatic creation of fio files enter the command FIO_NAME=%c%c\n\n",34,34) if (FIO_COPY != "") { printf("all fio files are automatically copied to the node:\n") printf("%s\n",FIO_COPY) printf("To stop this enter the command FIO_COPY=%c%c\n",34,34) } else { printf("the automatic copying of fio files is switched off,\n") printf("use macro fio_new_copy to switch it on.\n") } } else { printf("\nNo fio files will be created during scans.\n") printf("Use macro fio_new_filename to turn creation of fio files on.\n") } } ' # # # # ################################################################################# # # fio_new_copy # # hp 11.07.2000 # # creates new destination for the copying of fio files # ################################################################################ # def fio_new_copy ' { printf("\nfio_new_copy (hp) 11.07.2000\n") if ($# == 0) { _1 = getval("\nuser@computer:","user@idefix.mu.aps.anl.gov:") _2 = getval("directory","trashcan/") } else { _1 = "$1"; _2 = $2 } if (_1 == "") exit FIO_COPY = sprintf("%s%c%s%c",_1,34,_2,34) printf("files will be copied to %s\n",FIO_COPY) printf("to stop copying enter command: FIO_COPY=%c%c\n",34,34) } ' # # # # ################################################################################# # # fio_new_filename # # hp 11.07.2000 # # creates new filename und number for the fio files # ################################################################################ # def fio_new_filename ' { printf("\nfio_new_filename (hp) 11.07.2000\n") if ($# == 0) { _1 = getval("\nData file", FIO_NAME) _2 = FIO_NUMBER _2 = getval("Last scan number",_2) } else { _1 = "$1"; _2 = $2 } if (_1 == "") exit FIO_NAME = _1 FIO_NUMBER = _2 FIO_FILE = sprintf("%s%u.fio",FIO_NAME,FIO_NUMBER+1) if (file_info(FIO_FILE)) { print "Warning: file ",FIO_FILE," already exists." print "New output will be appended to old files!" } printf("to stop writing fio files enter command: FIO_NAME=%c%c\n",34,34) } ' # # # # ################################################################################# # # user_prescan_head # # hp 11.07.2000 # hp 14.08.2000 if the old FIO_FILE is still open it will be closed and copied # # define FIO_FILE and check if it allready exists # ################################################################################ # def user_prescan_head ' { if (FIO_NAME != "") { if (FIO_FILE != "") { if (!close(FIO_FILE)) _fio_copy_file if (MCA_ON >= 3) MCA_ON -= 1 } FIO_FILE = sprintf("%s%u.fio",FIO_NAME,++FIO_NUMBER) print "fio file: ",FIO_FILE if (file_info(FIO_FILE)) { print "Warning: file ",FIO_FILE," already exists." print "New output will be appended and makes it unreadable for Spectra!" } } _mca_erase_variables } ' # # # # ################################################################################# # # _mca_erase_variables # # hp 16.05.2001 # # executed by user_prescan_head, will be redefined by hp_mca.mac if necessary # ################################################################################ # def _mca_erase_variables '' # # # # ################################################################################# # # user_postscan_head # # hp 11.07.2000 # hp 14.08.2000 long headings will be truncated because of spectra problems # # write all necessary stuff into FIO_FILE before the real data starts # ################################################################################ # def user_postscan_head ' { local i,j,z,hpstr,n,hparray[] if (FIO_NAME != "") { open(FIO_FILE) # # writing fio comments # fprintf(FIO_FILE,"!\n") fprintf(FIO_FILE,"! Comment\n") fprintf(FIO_FILE,"%cc\n",37) fprintf(FIO_FILE,"Written by program user_postscan_head (hp) 11.07.2000\n") fprintf(FIO_FILE,"filename: %s\n",FIO_FILE) if (length(HEADING)<=60) { fprintf(FIO_FILE,"Scan_type = %s\n",HEADING) } else { hpstr = substr(HEADING,0,60) fprintf(FIO_FILE,"Scan_type = %s\n",hpstr) } fprintf(FIO_FILE,"This file was created at %s\n",DATE) # # writing fio parameter # fprintf(FIO_FILE,"!\n") fprintf(FIO_FILE,"! Parameter\n") fprintf(FIO_FILE,"%cp\n",37) fprintf(FIO_FILE,"sample_time = %g\n",_ctime) fprintf(FIO_FILE,"energy = %g\n",hc_over_e/LAMBDA) fprintf(FIO_FILE,"lambda = %g\n",LAMBDA) fprintf(FIO_FILE,"undulator_gap = %g\n",UNDULATOR_GAP) fprintf(FIO_FILE,"undulator_kev = %g\n",UNDULATOR_keV) fprintf(FIO_FILE,"temperature_set_point = %g\n",TEMP_SP) n = split(_hkl_val,hparray) j = 119 for (i=0;i= 0) fprintf(FIO_FILE," Col %u %s FLOAT\n",++j,cnt_name(z)) fprintf(FIO_FILE," Col %u %s FLOAT\n",++j,cnt_name(DET)) # # # off(FIO_FILE) } } ' # # # # ################################################################################# # # user_scan_loop # # hp 11.07.2000 # # write data into FIO_FILE # ################################################################################ # def user_scan_loop ' { local i if (FIO_NAME != "") { on(FIO_FILE) fprintf(FIO_FILE,"%s%s%d",FPRNT,Fout,(TIME_END=time())-EPOCH) for (i=0;i= 0) fprintf(FIO_FILE," %g",S[z]) fprintf(FIO_FILE," %g\n",S[DET]); off(FIO_FILE) } } ' # # # # ################################################################################# # # user_scan_tail # # hp 11.07.2000 # hp 14.08.2000 calls now _fio_copy_file instead of doing the copying by itself # # close FIO_FILE # ################################################################################ # def user_scan_tail ' { if (FIO_NAME != "") { if (!close(FIO_FILE)) { _fio_copy_file } else { printf("Unknown problem, could not close %s after scan.\n",FIO_FILE) printf("This problem is only serious if you write only fio files\n") printf("and no spec files, otherwise ignore it.\n") } } if (MCA_ON >= 3) MCA_ON -= 1 } ' # # # # ################################################################################# # # _fio_copy_file # # hp 14.08.2000 # # copy fio file to other workstation # ################################################################################ # def _fio_copy_file ' { local _s1 if (FIO_COPY != "") { print "copying data to",FIO_COPY _s1 = sprintf("scp -B %s %s 2> /dev/null &",FIO_FILE,FIO_COPY) unix(_s1) } } ' # # # # ################################################################################# # # _fio_mca_copy_file # # hp 14.08.2000 # hp 17.05.2001 # # copy fio file to other workstation # ################################################################################ # def _fio_mca_copy_file ' { local _s1 if (FIO_COPY != "") { if (MCA_ON < 3) { print "copying data to",FIO_COPY } _s1 = sprintf("scp -B %s %s 2> /dev/null &",mca_fname,FIO_COPY) unix(_s1) } } ' # # # #