;+ ;NAME: ; opsdb ;PURPOSE: ; Manage the IP queue and DEP memory resources ;HISTORY: ; Written Oct to Dec-95 by M.Morrison ; 5-Dec-95 (MDM) - Implemented ID assignments for campaigns and ; observations. ; 7-Dec-95 (MDM) - Incorporated new capabilities for "obstran" (the routine ; which converts from .obs files to .src). Capbilities ; were to allow the call to specify the address and slot. ; - Multiple changes to .CAM format ; 8-Dec-95 (MDM) - Changed the SIMP_CAM labels for prime30 label ; from OBS_PRIME30 to OBS_STD_STR30 ; - Modification to GET_ADDR to ignore the heritage load ; replacement addresses when finding the next available ; slot ; - Corrected error to GET_ADDR for OBS and CAM case ; ;FUTURE: ; * need to do conflict checks ;----------------------------------------------------------------- function opsdb_init_src_fil, file, qwrite=qwrite ; ; ; out = ['# File: ' + file, $ '#', $ 'program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"', $ '#=======================================================', $ '#', $ '#'] if (keyword_set(qwrite)) then begin file_delete, file file_append, file, out end ; return, out end ;----------------------------------------------------------------- function opsdb_get_struct ; ; ; out = {opsdb_ver10, type: ' ', label: ' ', id: 0L, descr: ' ', $ index: 0L, addr: 0L, nwords: 0L, forv: ' ', $ created: 0D, validated: 0D, loaded: 0D, removed: 0D, $ last_used: 0D, $ descr2: ' ', descr3: ' '} ; return, out end ;----------------------------------------------------------------- function fmt_duration, sec ; ; ; if (sec lt 0) then return, ' Still Present' ; temp = sec days = fix(temp/86400) & temp = temp - days*86400 hrs = fix(temp/60/60) & temp = temp - hrs*60*60 min = fix(temp/60) & temp = temp - min*60 sec = fix(temp) out = string(days, hrs, min, sec, format='(i3," days ", i2.2, ":", i2.2, ":", i2.2)') return, out end ;----------------------------------------------------------------- pro opsdb_rd_wrt, qread=qread, qwrite=qwrite, init=init, qbackup=qbackup ; ;+ ;METHOD: ; environment variable OPSDB_TYPE needs to be defined and the ; filename is derived as follows ; MDI_OPSDB_TYPE Filename ; ---------- -------- ; DEV opsdb_dev ; SIM opsdb_sim (needed?) ; PREP opsdb_prep ; FLIGHT opsdb_flt ; ; ; common opsdb_blk, dir, filnam, info ; case getenv('MDI_OPSDB_TYPE') of '': begin print, 'MDI_OPSDB_TYPE is not defined. Stopping. stop end 'DEV': filnam0 = 'opsdb_dev' 'SIM': filnam0 = 'opsdb_sim' 'PREP': filnam0 = 'opsdb_prep' 'FLIGHT': filnam0 = 'opsdb_flight' else: begin print, 'MDI_OPSDB_TYPE not recognized. Stopping... stop end endcase ; dir = getenv('MDI_OPS_IP_DEP') filnam = concat_dir( dir, filnam0) filnam2 = filnam + '.genx' ; if (keyword_set(init)) then begin info = opsdb_get_struct() return end ; if (keyword_set(qwrite)) then begin if (data_type(info) ne 8) then begin message, 'Write requested with no data defined', /info return end ; file_delete, filnam2 savegen, info, file=filnam end ; if (keyword_set(qbackup)) then begin if (data_type(info) ne 8) then begin message, 'Write requested with no data defined', /info return end ; fid = ex2fid(anytim2ex(!stime)) filnam2 = concat_dir(dir, filnam0 + fid) file_delete, filnam2 savegen, info, file=filnam2 print, 'Saving backup copies disabled tbeep, 3 end ; if (n_elements(info) eq 0) then qread = 1 if (keyword_set(qread)) then begin if (not file_exist(filnam2)) then begin message, 'Input file does not exist: ' + filnam, /info return end ; print, 'Restoring: ' + filnam restgen, info0, file=filnam n = n_elements(info0) info = replicate(opsdb_get_struct(), n) info = str_copy(info, info0) end ; end ;----------------------------------------------------------------- function opsdb_get_info, list, active=active, all=all, type=type, label=label, nostr=nostr, nmatch=nmatch, index=index ; ; ; common opsdb_blk, dir, filnam, info opsdb_rd_wrt ;make sure stuff has been read ; out = -1 ; if (data_type(info) ne 8) then begin message, 'No information defined return, out end ; sea_str = '' if (keyword_set(type)) then sea_str = [sea_str, '(strupcase(info.type) eq "' + strupcase(type) + '")'] ;if (keyword_set(label)) then sea_str = [sea_str, '(strupcase(info.label) eq "' + strupcase(label) + '")'] if (keyword_set(label)) then sea_str = [sea_str, "(strupcase(info.label) eq '" + strupcase(label) + "')"] if (keyword_set(active)) then sea_str = [sea_str, '(info.removed eq 0)'] if (keyword_set(all)) then sea_str = [sea_str, '(info.label ne "")'] if (n_elements(sea_str) eq 1) then begin print, 'OPSDB_GET_INFO: No search criteria specified' return, out end sea_str = arr2str(sea_str(1:*), delim=' and ') sea_str = 'out = where( ' + sea_str + ', nmatch)' ;;print, 'GET_INFO Sea_str: ', sea_str stat = execute(sea_str) if (keyword_set(nostr)) then return, out if (out(0) ne -1) then out = info(out) ; if (keyword_set(index)) then begin if (data_type(out) eq 8) then out = out.index $ else out = -1 end ; return, out end ;----------------------------------------------------------------- pro opsdb_rm_entry, label, all=all, obs=obs, cam=cam ; ; ; opsdb_rm_entry, label ; opsdb_rm_entry, /all ; opsdb_rm_entry, /obs ; opsdb_rm_entry, /cam ; ; common opsdb_blk, dir, filnam, info opsdb_rd_wrt ;make sure stuff has been read ; if (keyword_set(all)) then begin info2 = opsdb_get_info(/active) if (data_type(info2) ne 8) then return ;nothing to remove label = info2.label end ; if (keyword_set(obs)) then begin info2 = opsdb_get_info(type='OBS', /active) if (data_type(info2) ne 8) then return ;nothing to remove label = info2.label end ; if (keyword_set(cam)) then begin info2 = opsdb_get_info(type='CAM', /active) if (data_type(info2) ne 8) then return ;nothing to remove label = info2.label end ; n = n_elements(label) for i=0,n-1 do begin list2 = opsdb_get_info(label=label(i), /active, /nostr) if (list2(0) ge 0) then begin info(list2).removed = int2secarr(!stime, '1-Jan-58') print, 'Previous entry ' + label(i) + ' is being updated as removed' end end ; end ;----------------------------------------------------------------- pro opsdb_add_entry, info0, remove_old=remove_old, noindex=noindex ; ; common opsdb_blk, dir, filnam, info opsdb_rd_wrt ;make sure stuff has been read ; ; ss = where(strtrim(info0.label,2) eq '', nss) if (nss gt 0) then begin print, 'OPSDB_ADD_ENTRY: Sorry, there is a blank label in the requested update. print, 'OPSDB_ADD_ENTRY: No updates being made return end ; n = n_elements(info0) if (keyword_set(remove_old)) then opsdb_rm_entry, info0.label ; time = int2secarr(!stime, '1-Jan-58') info0.created = time info0.validated = time info0.loaded = time info = [info, info0] ; end ;----------------------------------------------------------------- pro opsdb_print, info, code, outfil=outfil, qstop=qstop, all=all, noheader=noheader, active=active, quiet=quiet ; ; if (keyword_set(all)) then info = opsdb_get_info(/all, active=active) ; if (keyword_set(outfil)) then begin file_delete, outfil openw, lun, outfil, /get_lun if (not keyword_set(noheader)) then begin printf, lun, 'OPSDB_PRINT Run ' + !stime printf, lun, ' ' end end if (n_elements(code) eq 0) then code = 0 n = n_elements(info) if (data_type(info) ne 8) then begin print, 'OPSDB_PRINT: Input must be a structure' return end ; case code of 0: tit = 'label/type/id addr/nwords 1: tit = 'Description and when loaded 2: tit = 'When loaded/remove and duration 3: tit = 'label/type/id/index addr/nwords st_add-en_addr in hex 99: tit = 'output to IPL else: begin Print, 'OPSDB_PRINT: Code ', code, ' not recognized' if (keyword_set(lun)) then free_lun, lun return end endcase ; for i=0,n-1 do begin info0 = info(i) for j=0,n_elements(tag_names(info0))-1 do if (data_type(info0.(j)) eq 7) then $ info0.(j) = info0.(j) + ' ' str1 = string( info0.label, info0.type, info0.id, format = '(1x, a24, a6, 1x, Z4.4)') str1b= string( info0.index, format='(i4)') str2 = string( info0.descr, format = '(1x, a60)') str3 = string( info0.addr, info0.nwords, format = '(1x, i6, i5)') str3b= string( info0.addr, info0.addr + info0.nwords-1, format = '(1x, "(", Z4.4, "-", Z4.4, ")")') if (code eq 1) or (code eq 2) then begin ;done for speed reasons str4a= ' ' + fmt_tim(anytim2ints('1-jan-58', off=info0.created)) str4c= ' ' + fmt_tim(anytim2ints('1-jan-58', off=info0.loaded)) str4d= ' ' + fmt_tim(anytim2ints('1-jan-58', off=info0.removed)) end str99= string( info0.label, info0.descr2, info0.addr, info0.type, info0.nwords, format='(a24, a12, i8, 2x, a12, i6)') case code of 0: str = str1 + str3 1: str = str1 + str2 + str4a 2: str = str1 + str4c + ' -->' + str4d + fmt_duration( info0.removed - info0.loaded ) 3: str = str1 + str1b + str3 + str3b 99: str = str99 endcase if (not keyword_set(quiet)) then print, str if (keyword_set(lun)) then printf, lun, str end ; if (keyword_set(lun)) then free_lun, lun if (keyword_set(qstop)) then stop end ;----------------------------------------------------------------- function opsdb_get_id, type, index=index ; ; ; id = opsdb_get_id('OBS') ; index = opsdb_get_id('OBS', /index) ; ;HISTORY: ; Written 5-Dec-95 by M.Morrison ; 7-Dec-95 (MDM) - Added /INDEX option ; common opsdb_blk, dir, filnam, info opsdb_rd_wrt ;make sure stuff has been read ; list2 = opsdb_get_info(type=type) if (data_type(list2) eq 8) then begin id_arr = list2.id if (keyword_set(index)) then id_arr = list2.index out = max(id_arr)+1 end else begin out = 8 end ; return, out end ;----------------------------------------------------------------- function opsdb_get_addr, info00, queue=queue, ipregister=ipregister, pad=pad, $ cam=cam, obs=obs ; ; ; ;HISTORY: ; Written Aug-95 by M.Morrison ; 13-Sep-95 (MDM) - Added PAD option ; 5-Dec-95 (MDM) - Added CAM and OBS option to get those addresses ; common opsdb_blk, dir, filnam, info opsdb_rd_wrt ;make sure stuff has been read ; if (data_type(info00) ne 8) then begin ;TODO - sloppy funny way to do this.... info00 = opsdb_get_struct() info00.addr = -99 if (keyword_set(queue)) then info00.type = 'QADR' if (keyword_set(ipregister)) then info00.type = 'IPRL' if (keyword_set(obs)) then info00.type = 'OBS' if (keyword_set(cam)) then info00.type = 'CAM' end ; n = n_elements(info00) out = lonarr(n) ; for i=0,n-1 do begin info0 = info00(i) addr = info0.addr if (addr le 0) then begin ;has not been assigned yet list2 = opsdb_get_info(type= info0.type, /active) addr_arr = -1 if (data_type(list2) eq 8) then begin addr_arr = list2.addr nwords_arr = list2.nwords if ((info0.type eq 'IPRL') or (info0.type eq 'QADR')) then begin ss33 = where(addr_arr lt '1f00'x, nss33) ;MDM added 8-Dec-95 to avoid the heritage load replacement if (nss33 eq 0) then begin addr_arr = -1 end else begin addr_arr = addr_arr(ss33) nwords_arr = nwords_arr(ss33) end end end if (max(addr_arr) le 0) then begin ;none of that type done yet case info0.type of 'IPRL': addr = 4096 'QADR': addr = '1000'x 'CAM': addr = '1088'x 'OBS': addr = '3AEC'x ;'4000'x - other portion for dynamics,str50,str30,mag30,hdr15,tail15 else: addr = -1000 endcase end else begin ;;dummy = max(addr_arr, imax) ;;addr = addr_arr(imax) + nwords_arr(imax) ;move to the next available location addr = max(addr_arr + nwords_arr, imax) if (info0.type eq 'OBS') then addr = min(addr_arr) ;opposite direction filling up if (info0.addr eq -1) then addr = addr > 4096 ;A1 area starts at 4096 ;--- TODO - implement areas of register space?? ;--- TODO - check for out of bounds (gone too far) ; if (keyword_set(pad)) then addr = addr + pad ;give some buffer space for expansion of code space if (addr ge '1f00'x) and ((info0.type eq 'IPRL') or (info0.type eq 'QADR')) then begin message, 'Address is beyond 0x1f00. Stopping....' end end ; info0.addr = addr info0.loaded = int2secarr(!stime, '1-Jan-58') ;;print, 'INFO0.LABEL = ', info0.label if (strtrim(info0.label,2) ne '') then begin ;;print, 'Updating database. Addr,loaded=',info0.addr, info0.loaded list2 = opsdb_get_info(label=info0.label, /active, /nostr, nmatch=n2) case n2 of 0: ;not even possible? 1: begin info(list2).addr = info0.addr ;because of IDL funny info(list2).loaded = info0.loaded end else: begin print, '>>> Multiple label entries: ' + info0.label info(list2).addr = lonarr(n2)+info0.addr info(list2).loaded = dblarr(n2)+info0.loaded end endcase end end out(i) = addr info00(i) = info0 ;update the input array end ; return, out end ;----------------------------------------------------------------- pro opsdb_mk_ipvec_src, infil0, do_load_file=do_load_file ; ; ; common opsdb_blk, dir, filnam, info ; infil = infil0 + '.ipv' outfil = '../src/' + infil0 + '.src' mat = rd_tfile(infil, 2, delim=string(9b), nocomm='#') ss = where(mat(0,*) ne '', nss) if (nss eq 0) then begin tbeep, 3 message, 'No information in ' + infil return end mat = mat(*,ss) ; out = opsdb_init_src_fil(outfil) ; n = n_elements(mat(0,*)) for i=0,n-1 do begin addr = opsdb_get_addr(opsdb_get_info(label=mat(1,i),/active)) out0 = 'tcblock mbipcmd 0x91 ' + mat(0,i) + string(addr, format='(3x, "0x", z4.4)') + ' ## ' + mat(1,i) out = [out, out0] ; ss = opsdb_get_info(label=mat(1,i),/active,/nostr) if (ss(0) ne -1) then info(ss(0)).index = fix(mat(0,i)) ;set the index -- MDM added 9-Nov-95 end file_delete, outfil prstr, out, file=outfil if (keyword_set(do_load_file)) then file_append, do_load_file, 'perf ' + infil0 end ;----------------------------------------------------------------- pro opsdb_mk_ips_src, infil, addr, direct_load=direct_load, $ do_load_file=do_load_file, init_do_load=init_do_load, $ pad=pad, replace=replace ; ; ;HISTORY: ; Written Aug-95 by M.Morrison ; 13-Sep-95 (MDM) - Added PAD and REPLACE options ; spawn, ['egrep', '-i', '::', infil +'.ips'], result, /noshell if (result(0) ne '') then begin ;remove labels from database if running them again labels = strtrim(result, 2) for i=0,n_elements(labels)-1 do labels(i) = (str2arr(labels(i), '::'))(0) ;remove :: and onward if (keyword_set(replace) and (not keyword_set(addr))) then addr = opsdb_get_addr(opsdb_get_info(label=labels(0),/active)) opsdb_rm_entry, labels end ; cmd = concat_dir(getenv('MDI_EXE_DIR'), 'ipl') if (keyword_set(direct_load)) then begin opsdb_mk_reg_ips, infil+'.tab' cmd = [cmd, '-l', infil] end else begin if (not keyword_set(addr)) then addr = opsdb_get_addr(/queue, pad=pad) cmd = [cmd, '-a', strtrim(addr,2), infil] end ; opsdb_mk_ipl_in ; file_delete, 'IP_Symbols.new' print, '>>>>>>>>>>>>>>>>>>> ' + arr2str(cmd, delim=' ') spawn, cmd, /noshell ; if (not file_exist('IP_Symbols.new')) then begin ;linker did not run successfully print, '************ Error during IP linker execution ******************** print, 'Stopping......' stop ;return end ; spawn, ['mv', infil+'.src', '../src/.'], /noshell ;move the .src file into the proper directory ; opsdb_rd_addr_file, 'IP_Symbols.new', info nn = n_elements(info) if (nn gt 2) then begin if (info(2).addr ne info(0).addr) then begin print, 'OPSDB_MK_IPS_SRC: First label in IPS file is not at the top of the file stop end ;info(2).nwords = info(0).nwords ;info(2:*).nwords = info(1).addr - info(2:*).addr + 1 info = [info, info(1)] ;put a copy of the stop address at the end info(nn).addr = info(nn).addr + 1 ;next available address info(2:nn-1).nwords = info(3:*).addr - info(2:nn-1).addr info.forv = infil opsdb_add_entry, info(2:nn-1), /remove_old ;don't log start/end address ;/remove_old needed for /replace option to work properly end ; if (keyword_set(do_load_file)) then begin if (keyword_set(init_do_load)) then junk = opsdb_init_src_fil(do_load_file, /qwrite) file_append, do_load_file, 'perf ' + infil end ; end ;----------------------------------------------------------------- pro opsdb_mk_reg_ips, infil, outfil ; ; opsdb_mk_reg_ips, 'images_reg.tab' ; ; opsdb_rd_addr_file, infil, info if (data_type(info) ne 8) then return opsdb_add_entry, info, /remove_old ; if (n_elements(outfil) eq 0) then outfil = str_replace(infil, '.tab', '.ips') openw, lun, outfil, /get_lun printf, lun, '; OPSDB_MK_REG_IPS Program Run: ' + !stime printf, lun, '; Input File: ' + infil printf, lun, '; ; n = n_elements(info) ; for i=0,n-1 do begin info0 = info(i) addr = opsdb_get_addr(info0) if (strtrim(info0.forv,2) eq "") then begin print, 'No values for label ' + info0.label print, 'No SETREG instruction generated end else begin values = str_replace(info0.forv, ',', ' ') ; ss = where(byte(info0.forv) eq (byte(','))(0), nss) & nvalues = nss + 1 ss = where(byte(info0.forv) eq (byte('L'))(0), nss) & nvalues = nvalues + nss ss = where(byte(info0.forv) eq (byte(':'))(0), nss) & nvalues = nvalues + nss if (nvalues ne info0.nwords) then begin print, 'Problem with: ', info0.label print, 'Values String: ', info0.forv print, 'Expected # of values: ', info0.nwords print, 'Determined # of values: ', nvalues stop end ; if (info0.nwords eq 1) then begin str = string('SETREG', addr, values, format='(a, 1x, "R",i4.4, 1x, a)') end else begin str = string('SETREGS', addr, info0.nwords, values, format='(a, 1x, "R",i4.4, 1x, i3, 1x, a)') end print, ';' print, ';' + info0.label print, str printf, lun, ';' printf, lun, ';' + info0.label printf, lun, str end end ; free_lun, lun end ;----------------------------------------------------------------- pro opsdb_rd_addr_file, infil, info, update=update ; ; ; info = 0b mat = rd_tfile(infil, nocomment=';') remtab, mat, mat mat = strtrim(mat, 2) ss = where(mat ne '') if (ss(0) eq -1) then mat = '' else mat = mat(ss) n = n_elements(mat) if (mat(0) eq '') then begin print, 'OPSDB_RD_IPL_OUT: Error reading ' + infil return end ; info = replicate(opsdb_get_struct(), n) for i=0,n-1 do begin lin = strtrim(strcompress(mat(i)), 2) arr = str2arr(lin, delim=' ') narr = n_elements(arr) if (narr lt 5) then begin print, 'OPSDB_RD_ADDR_FILE: Problem with reading an address file print, '>>>>>>>>>>>>>>>> ' + lin tbeep end else begin case strmid(arr(2), 0, 1) of 'A': arr(2) = '-' + strmid(arr(2), 1, 99) ;make it a negative number 'R': arr(2) = strmid(arr(2), 1, 99) else: if (strmid(arr(2), 0, 2) eq '0x') then begin temp = 0L reads, strmid(arr(2), 2, 99), temp, format='(z)' arr(2) = temp end end info(i).label = arr(0) info(i).descr2 = arr(1) ;instruction info(i).addr = arr(2) info(i).type = arr(3) info(i).nwords = long(arr(4)) if (narr ge 6) then begin values = arr2str(arr(5:*)) info(i).forv = values if (strlen(values) gt 40) then begin print, 'Problem with ', info(i).label print, 'Values string is too long. # characters = ', strlen(values) print, 'String == ' + values tbeep, 4 ;;stop end end end end ; if (keyword_set(update)) then opsdb_add_entry, info, /remove_old end ;----------------------------------------------------------------- pro opsdb_mk_ipl_in ; ; ; outfil = 'IP_Symbols.dat' file_delete, outfil ; info = opsdb_get_info(/active) n = n_elements(info) for i=0,n-1 do for j=0,n_elements(tag_names(info))-1 do if (data_type(info.(j)) eq 7) then if (strtrim(info(i).(j),2) eq '') then info(i).(j) = '---' opsdb_print, info, 99, outfil=outfil, /noheader, /quiet end ;----------------------------------------------------------------- pro opsdb_check_code, files ; ; opsdb_check_code, findfile('*.ips') ; for ifil=0,n_elements(files)-1 do begin infil = files(ifil) print, '---------------- Checking ' + infil ; mat = rd_tfile(infil, nocomment=';') remtab, mat, mat mat = strupcase(strcompress(strtrim(mat, 2))) ; ss = wc_where(mat, '*COPYR?2?*', nss) ss = wc_where(mat, '*COPYR*', nss) print, ' # of COPYR* commands == ', nss for i=0,nss-1 do begin arr = str2arr(mat(ss(i)), delim=' ') if (arr(0) ne 'COPYREG') then if (fix(arr(3)) le 2) then print, mat(ss(i)) end end ; end ;----------------------------------------------------------------- pro test1 opsdb_rd_wrt, /qread opsdb_rd_wrt, /qbackup opsdb_rd_wrt, /init info = opsdb_get_struct() info.label = 'test_lab1' info.type = 'iprl' info.addr = -999 opsdb_add_entry, info ; opsdb_rd_wrt, /qwrite ; end ;----------------------------------------------------------------- pro test2, info info = opsdb_get_info(label='test_lab1') end ;----------------------------------------------------------------- pro test3 ; ; ; idl_speed dbclose opsdb_mk_reg_ips, 'images_reg.tab' opsdb_mk_ipl_in idl_speed, 1 end ;----------------------------------------------------------------- pro test4 info = opsdb_get_struct() idl_speed & for i=1,10 do opsdb_add_entry, info & idl_speed, 1 ;0.50 per entry idl_speed & for i=1,10 do opsdb_add_entry, info, /noindex & idl_speed, 1 ;0.16 per entry idl_speed & for i=1,10 do info = opsdb_get_info(label='test_lab1') & idl_speed,1 ;0.31 sec idl_speed & for i=1,10 do info = opsdb_get_info(label='test_lab1',/nostr) & idl_speed,1 ;0.06 sec idl_speed & for i=1,10 do info = opsdb_get_info(/all,/nostr) & idl_speed,1 ;0.07 sec idl_speed & for i=1,10 do dbindex & idl_speed, 1 ;0.30 sec idl_speed & for i=1,10 do list = dbfind('label', /silent) & idl_speed,1 ;0.03 sec idl_speed & for i=1,10 do list = dbfind('label=test_lab1,removed=0', /silent) & idl_speed,1 ;0.06 sec idl_speed & for i=1,10 do addr = opsdb_get_addr(/queue) & idl_speed,1 ;0.20 sec (old=1.30 sec) idl_speed & for i=1,10 do dbupdate, 1, 'removed', dblarr(1) & idl_speed,1 ;0.09 sec idl_speed & for i=1,100 do a=int2secarr(!stime, '1-Jan-58') & idl_speed,1 ;0.03 sec end ;----------------------------------------------------------------- pro test4b ; test1 idl_speed & for i=1,10 do opsdb_add_entry, info, /noindex & idl_speed, 1 ;0.16 per entry ; OPSDB_OPEN & DBINDEX idl_speed & for i=1,10 do addr = opsdb_get_addr(/queue) & idl_speed,1 ;1.30 sec ;^^^ will crash unless there is a OPSDB_OPEN & DBINDEX between them end ;----------------------------------------------------------------- pro test5 ; opsdb_open, /create info = opsdb_get_struct() ; info.label = string(systime(1), format='(f12.2)') & opsdb_add_entry, info info.label = string(systime(1), format='(f12.2)') & opsdb_add_entry, info, /noindex opsdb_print, /all print, 'No building the index' dbindex opsdb_print, /all ;==> cannot find an entry until the index is built. ; end ;----------------------------------------------------------------- pro test_samp_prob test1 opsdb_mk_ips_src, 'mk_vel' ;supposed to have done hdecode and header before end ;----------------------------------------------------------------- pro test_samp ; opsdb_mk_ips_src, 'samp3_reg', /direct_load opsdb_mk_ips_src, 'do_hdecode' opsdb_mk_ips_src, 'do_header' opsdb_mk_ips_src, 'mk_vel' opsdb_mk_ips_src, 'fmt_extract' opsdb_mk_ips_src, 'dl_1page' opsdb_mk_ips_src, 'samp3' end ;----------------------------------------------------------------- pro test_tap ; opsdb_mk_ips_src, 'samp3_reg', /direct_load opsdb_mk_ips_src, 'tap_burst_reg', /direct_load opsdb_mk_ips_src, 'do_hdecode' opsdb_mk_ips_src, 'do_header' opsdb_mk_ips_src, 'fmt_extract' opsdb_mk_ips_src, 'dl_1page' opsdb_mk_ips_src, 'mk_fltgram' opsdb_mk_ips_src, 'tap_cont opsdb_mk_ips_src, 'tap_burst opsdb_mk_ips_src, 'mk_vel' opsdb_mk_ips_src, 'samp3' opsdb_print, /all, /active, outfil='test_tap.list' print, 'lland *.ips *.tab test_tap.list' end ;----------------------------------------------------------------- pro test_scott0 ; ; ; opsdb_mk_ips_src, 'ip_test', '1d00'x opsdb_mk_ips_src, 'ipcntrl';, '1d80'x opsdb_mk_ips_src, 'dmpmem';, '1e00'x opsdb_mk_ips_src, 'dmptbls';, '1e40'x opsdb_mk_ips_src, 'comp5k';, '1e80'x opsdb_mk_ips_src, 'images', '1f00'x ; opsdb_print, /all, /active end ;----------------------------------------------------------------- pro test_scott ; ; ; opsdb_mk_ips_src, 'ipcntrl', '1c00'x opsdb_mk_ips_src, 'comp5k', '1c43'x opsdb_mk_ips_src, 'iptstld', '1d00'x opsdb_mk_ips_src, 'dmpmem', '1e38'x opsdb_mk_ips_src, 'dmptbls', '1e57'x opsdb_mk_ips_src, 'images', '1f00'x ; opsdb_print, /all, /active,outfil='summary_list.txt',xx,3 end ;----------------------------------------------------------------- pro test_all, init=init, skip=skip ; ; ; if (keyword_set(init)) then test1 if (keyword_set(skip)) then case skip of 1: goto, skip1 2: goto, skip2 3: goto, skip3 endcase ; skip1: ; cd, '/mdisw/cfl/dev2/ip load_file = '../src/ld_cam_ip.src' opsdb_mk_ips_src, 'cam_reg', /direct_load , do_load_file=load_file, /init_do_load ; opsdb_mk_ips_src, 'do_hdecode' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'do_header' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'reset_tlm' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'downlink' , pad=40, do_load_file=load_file ; opsdb_mk_ips_src, 'do_dump_ipreg' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'debug_ipreg' , pad=40, do_load_file=load_file ; opsdb_mk_ips_src, 'fmt_extract' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'fmt_bin' , pad=40, do_load_file=load_file ; opsdb_mk_ips_src, 'mk_fltgram' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'mk_vel' , pad=40 ;;, do_load_file=load_file ; opsdb_mk_ips_src, 'tap_cont' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'tap_burst' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'fltgram' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'dump_ipreg' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'prime00' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'mag_dl_setup' , pad=40, do_load_file=load_file opsdb_mk_ips_src, 'vc2_obs' , pad=40, do_load_file=load_file opsdb_mk_ipvec_src, 'set_ipvectors', do_load_file=load_file ;----------------- UOBS, CAM and OFFSET stuff skip2: cd, '/mdisw/cfl/dev2/dep load_file = '../src/ld_cam_dep.src' opsdb_mk_tab_src, 'offset.tab', do_load_file=load_file, /init_do_load opsdb_mk_obs_src, 'obs_prime00.uobs', do_load_file=load_file ;, index=7 opsdb_mk_obs_src, 'obs_test_tapc1.uobs', do_load_file=load_file ;, index=8 opsdb_mk_obs_src, 'obs_test_tapc2.uobs', do_load_file=load_file ;, index=9 opsdb_mk_obs_src, 'obs_test_tapc3.uobs', do_load_file=load_file ;, index=10 opsdb_mk_obs_src, 'obs_vc2_obs.uobs', do_load_file=load_file ;, index=10 opsdb_mk_cam_src, 'cam_test_tapc1.cam', do_load_file=load_file opsdb_mk_cam_src, 'cam_test_tapc2.cam', do_load_file=load_file opsdb_mk_cam_src, 'cam_test_tapc3.cam', do_load_file=load_file opsdb_mk_cam_src, 'cam_vc2_obs.cam', do_load_file=load_file ;----------------- UOBS and CAM stuff for commisioning skip3: cd, '/mdisw/cfl/comm/dep load_file = '../src/ld_comm_dep.src' ff = findfile('/mdisw/cfl/comm/dep/*.uobs') break_file, ff, dsk_log, dir, filnam for i=0,n_elements(filnam)-1 do opsdb_mk_obs_src, filnam(i) + '.uobs', do_load_file=load_file, init_do_load=(i eq 0) for i=0,n_elements(filnam)-1 do opsdb_mk_simp_cam, filnam(i) ;make .cam files ; ff = findfile('/mdisw/cfl/comm/dep/*.cam') break_file, ff, dsk_log, dir, filnam, ext for i=0,n_elements(filnam)-1 do opsdb_mk_cam_src, filnam(i)+'.cam', do_load_file=load_file ;go from .cam to .src for campaign lists opsdb_print, /all, /active, outfil='opsdb_cam.list',xx,3 opsdb_rd_wrt, /qwrite print, 'lland *.ips *.tab opsdb_cam.list' end ;----------------------------------------------------------------- pro fixup_by_hand opsdb_mk_ips_src, 'do_hdecode', '0100'x end ;----------------------------------------------------------------- pro test_replace, infil if (n_elements(infil) eq 0) then infil = 'do_header' opsdb_mk_ips_src, infil , pad=40, /replace opsdb_rd_wrt, /qwrite ; cmd = concat_dir(getenv('MDI_TASK_DIR'), 'egse_cmd') spawn, [cmd, 'compile', infil], result, /noshell & prstr, result & pause spawn, [cmd, 'perf', infil], result, /noshell & prstr, result & pause ; spawn, [cmd, 'perf', 'reset'], result, /noshell & prstr, result & pause spawn, [cmd, 'perf', 'test1'], result, /noshell & prstr, result end ;----------------------------------------------------------------- pro opsdb_mk_frm_src, infil ; ; opsdb_mk_frm_src, 'dt19_cal.obs' ; ; if (not file_exist(infil)) then begin print, 'Input file: ' + infil + ' does not exist return end ; spawn, ['cp', 'DEP_Lists.MAP0', 'DEP_Lists.MAP'], /noshell ;start with the list with only std 6 plus PRIME00 spawn, ['obstran', str_replace(infil, '.obs', '')], /noshell src_fil = str_replace(infil, '.obs', '.src') spawn, ['mv', src_fil, '../src'], /noshell spawn, ['grep', '-i', 'Name:', infil], result, /noshell p = strpos(result(0), ':') name = strtrim(strmid(result(0), p+1, 99),2) + ' ' name = strmid(name, 0, strpos(name, ' ')) ; spawn, ['grep', '-i', 'Description:', infil], result, /noshell p = strpos(result(0), ':') descr = strtrim(strmid(result(0), p+1, 99),2) ; map = rd_tfile('DEP_Lists.MAP') arr = str2arr(strcompress(map(0)), delim=' ') index = strtrim(fix(arr(2))-1,2) ; ss = where(strtrim(map,2) ne '') map = map(ss) arr = str2arr(strcompress(map(n_elements(map)-1)), delim=' ') id = arr(1) addr = 0L reads, arr(2), addr ; info = opsdb_get_struct() info.label = name info.index = index info.id = id info.addr = addr info.descr = descr info.forv = infil info.type = 'OBS' opsdb_add_entry, info, /remove_old end ;----------------------------------------------------------------- pro opsdb_mk_tab_src, infil, addr, do_load_file=do_load_file, init_do_load=init_do_load ; ; opsdb_mk_tab_src, 'offset.tab' ; ; if address is not specified, then first characters must be "offset" or "exposure" ; if (not file_exist(infil)) then begin print, 'Input file: ' + infil + ' does not exist return end ; break_file, infil, dsk_log, dir00, filnam00 outfil = '../src/' + infil outfil = str_replace(outfil, '.tab', '.src') ; mat = rd_tfile(infil, 4, nocomment='#', delim=string(9b)) mat = mat(*,2:*) ;drop header and ---- lines ; if (n_elements(addr) eq 0) then begin addr = 0 if (strmid(filnam00, 0, 6) eq 'offset') then addr = '4098'x if (strmid(filnam00, 0, 8) eq 'exposure') then addr = '4498'x if (addr eq 0) then stop ;what to do end ; n = n_elements(mat(0,*)) ; out = opsdb_init_src_fil(outfil) ; fmt = '("tcb mbdpml 0x1000 ", 3(" 0x", Z4.4), 6x, 3(a,1x))' ; for i=0,n-1 do begin addr2 = addr + mat(0,i)*4 ;4 bytes per entry value = mat(1,i) low8 = value mod 2L^16 hi8 = value / 2L^16 out = [out, string(addr2, low8, hi8, "## "+mat(1,i), mat(3,i), format=fmt)] end ; out = strmid(out, 0, 78) ;trim it down to make sure no compile problems out = [out, ' ', 'return'] ; prstr, out, /nomore prstr, out, file=outfil ; if (keyword_set(do_load_file)) then begin if (keyword_set(init_do_load)) then junk = opsdb_init_src_fil(do_load_file, /qwrite) file_append, do_load_file, 'perf ' + filnam00 end end ;----------------------------------------------------------------- pro opsdb_mk_obs_src, infil, addr, do_load_file=do_load_file, init_do_load=init_do_load, index=index ; ; opsdb_mk_obs_src, 'obs_focus_1.uobs' ; if (not file_exist(infil)) then begin print, 'Input file: ' + infil + ' does not exist return end ; id = -1 break_file, infil, dsk_log, dir, filnam, ext if (ext eq '.uobs') then begin id = opsdb_get_id('OBS') print, 'OPSDB_MK_OBS_SRC: ID = ' + strtrim(id,2) opsdb_uobs2obs, infil, id=id ;convert from uobs to obs infil = str_replace(infil, '.uobs', '.obs') end ; if (not file_exist(infil)) then begin print, 'Input file: ' + infil + ' does not exist return end mat = rd_tfile(infil) load_size = (n_elements(mat)-6) * 12 if (n_elements(addr) eq 0) then begin addr = opsdb_get_addr(/obs) addr = addr - load_size print, 'OPSDB_MK_OBS_SRC: Address = ' + strtrim(addr,2) end addr = addr(0) ; if (n_elements(index) eq 0) then index = opsdb_get_id('OBS', /index) ; cmd = concat_dir(getenv('MDI_EXE_DIR'), 'obstran') cmd = [cmd, '-a', strtrim(addr-'1088'x, 2), '-s', strtrim(index,2), str_replace(infil, '.obs', '')] ;cmd = [cmd, str_replace(infil, '.obs', '')] print, arr2str(cmd, delim=' ') spawn, cmd, result, /noshell if (result(0) ne '') then begin print, 'Trouble with obstran' prstr, result stop end ; src_fil = str_replace(infil, '.obs', '.src') spawn, ['mv', src_fil, '../src'], /noshell spawn, ['grep', '-i', 'Name:', infil], result, /noshell p = strpos(result(0), ':') name = strtrim(strmid(result(0), p+1, 99),2) + ' ' name = strmid(name, 0, strpos(name, ' ')) ; spawn, ['grep', '-i', 'Description:', infil], result, /noshell p = strpos(result(0), ':') descr = strtrim(strmid(result(0), p+1, 99),2) ; info = opsdb_get_struct() info.label = name info.index = index info.id = id info.addr = addr info.nwords = load_size info.descr = descr info.forv = infil info.type = 'OBS' opsdb_add_entry, info, /remove_old ; if (keyword_set(do_load_file)) then begin if (keyword_set(init_do_load)) then junk = opsdb_init_src_fil(do_load_file, /qwrite) file_append, do_load_file, 'perf ' + filnam end ; end ;----------------------------------------------------------------- pro opsdb_mk_cam_src, infil, addr, do_load_file=do_load_file, init_do_load=init_do_load ; ; opsdb_mk_cam_src, 'cam_dt19_cal.cam' ; if (not file_exist(infil)) then begin print, 'Input file: ' + infil + ' does not exist return end ; break_file, infil, dsk_log, dir00, filnam00 outfil = '../src/' + infil outfil = str_replace(outfil, '.cam', '.src') ; mat = rd_tfile(infil, nocomment='#') remtab, mat, mat mat = strtrim(strcompress(mat),2) ss = where(mat ne '') mat = mat(ss) mat2 = rd_tfile(infil, 2, nocomment='#') if (n_elements(mat2(0,*)) lt 7) then begin message, 'bad cam file: ' + infil, /info return end ; ihead = opsdb_get_info(label=mat2(1,2),/index,/active) & if (ihead eq -1) then ihead = 4 ;not in database yet itail = opsdb_get_info(label=mat2(1,3),/index,/active) & if (itail eq -1) then itail = 5 ;not in database yet iprime = opsdb_get_info(label=mat2(1,4),/index,/active) & if (iprime eq -1) then iprime = 2 ;not in database yet ialt30 = opsdb_get_info(label=mat2(1,5),/index,/active) & if (ialt30 eq -1) then ialt30 = 3 ;not in database yet ; if (n_elements(addr) eq 0) then addr = opsdb_get_addr(/cam) addr = addr(0) id = opsdb_get_id('CAM') n = n_elements(mat)-6 ; out = opsdb_init_src_fil(outfil) ; fmt0= '("tcb mbdpml 0x1000 ", 3(" 0x", Z4.4), 20x, a)' fmt = '("tcb mbdpml 0x1000 ", 5(" 0x", Z4.4), 6x, a)' out = [out, string(addr, id, n, "## ID, N", format=fmt0)] out = [out, string(addr+4+8*0, ihead, 1, '7fff'x, 0, "## Head", format=fmt)] out = [out, string(addr+4+8*1, itail, 1, '7fff'x, 0, "## Tail", format=fmt)] out = [out, string(addr+4+8*2, iprime, 1, '7fff'x, 0, "## Prime30", format=fmt)] out = [out, string(addr+4+8*3, ialt30, 'ffff'x, '7fff'x, 0, "## Alt30", format=fmt)] ; for i=0,n-1 do begin arr = str2arr(mat(i+6), delim=' ') info = opsdb_get_info(label = arr(0), type='OBS', /active) if (data_type(info) ne 8) then begin print, 'Cannot find observation: ' + arr(0) + ' in the database' print, '************* Aborting' return end iobs = info(0).index ; irep = fix(arr(1)) ipprog = '7fff'x ;TODO - allow redirection offset = fix(arr(3)) out = [out, string(addr+4+8*(i+4), iobs, irep, ipprog, offset, "## "+arr(0), format=fmt)] end ; out = [out, ' ', 'return'] ; prstr, out prstr, out, file=outfil ; src_fil = str_replace(infil, '.cam', '.src') spawn, ['grep', '-i', 'Name:', infil], result, /noshell p = strpos(result(0), ':') name = strtrim(strmid(result(0), p+1, 99),2) + ' ' name = strmid(name, 0, strpos(name, ' ')) ; spawn, ['grep', '-i', 'Description:', infil], result, /noshell p = strpos(result(0), ':') descr = strtrim(strmid(result(0), p+1, 99),2) ; info = opsdb_get_struct() info.label = name info.id = id info.addr = addr info.nwords = 4 + (4+n)*8 info.descr = descr info.index = (addr-'1088'x)/2 info.forv = infil info.type = 'CAM' opsdb_add_entry, info, /remove_old ; if (keyword_set(do_load_file)) then begin if (keyword_set(init_do_load)) then junk = opsdb_init_src_fil(do_load_file, /qwrite) file_append, do_load_file, 'perf ' + filnam00 end ; end ;----------------------------------------------------------------- pro opsdb_mk_simp_cam, filnam ; ; ; opsdb_mk_simp_cam, 'obs_focus_1' ; outlab = 'cam_' + strmid(filnam,4,99) outfil = outlab + '.cam' ; spawn, ['grep', '-i', 'OFFSET:', filnam+'.uobs'], result, /noshell p = strpos(result(0), ':') if (p eq -1) then offset = '0' $ else offset = strtrim(strmid(result(0), p+1, 99),2) ; out = ['#', $ '# FILE:', $ '# ' + outfil, $ '# HISTORY:', $ '# Auto Created by OPSDB_MK_SIMP_CAM ' + !stime, $ '#', $ 'Campaign_Name: ' + outlab, $ 'Campaign_Description: UNKNOWN', $ ' ', $ 'HEAD OBS_STD_HEAD', $ 'TAIL OBS_STD_TAIL', $ 'PRIME30 OBS_STD_STR30', $ 'ALT30 OBS_STD_ALT30', $ ' ', $ '# ObsName Repeats IP_Prog Offset',$ filnam + ' 1 DEFAULT '+offset] prstr, out, file=outfil end ;----------------------------------------------------------------- pro test_comm ; ; setenv,'MDI_OPSDB_TYPE=SIM' ; ff = findfile('/mdisw/cfl/comm/dep/*.uobs') break_file, ff, dsk_log, dir, filnam n=n_elements(filnam) ; ;;for i=0,n-1 do opsdb_uobs2obs, ff(i), /sim ;go from .uobs to .obs for frame list ;;cd,'/mdisw/cfl/comm/dep' ;;for i=0,n-1 do opsdb_mk_frm_src, filnam(i)+'.obs' ;go from .obs to .src for frame list cd, dir(0) for i=0,n-1 do opsdb_mk_obs_src, filnam(i) + '.uobs' ; ;;for i=0,n-1 do opsdb_mk_simp_cam, filnam(i) ;make .cam files ; ;;for i=0,n-1 do opsdb_mk_cam_src, 'cam_'+filnam(i)+'.cam' ;go from .cam to .src for campaign list ; ff = findfile('/mdisw/cfl/comm/dep/*.cam') break_file, ff, dsk_log, dir, filnam, ext n=n_elements(filnam) for i=0,n-1 do opsdb_mk_cam_src, filnam(i)+'.cam' ;go from .cam to .src for campaign lists ; end ;----------------------------------------------------------------- function decode_trans_obs, value, lab, item, qinteger, err ; ; ; value0 = value p1 = strpos(value, '+') & if (p1 ne -1) then value0 = strmid(value, 0, p1) p2 = strpos(value, '-') & if (p2 ne -1) then value0 = strmid(value, 0, p2) ss = where((lab(0,*) eq item) and (lab(1,*) eq value0), nss) if (nss ne 0) then begin out = lab(2, ss(0)) if (p1 ne -1) then out = fix(out) + fix(strmid(value, p1+1, 99)) if (p2 ne -1) then out = fix(out) - fix(strmid(value, p2+1, 99)) if (qinteger) then out = fix(out) return, out end ; if (strmid(value, 0, 3) eq 'ABS') then begin v = strmid(value, 3, 99) arr = str2arr(v) out = fix(arr(0)) if (n_elements(arr) eq 2) and (strmid(item, 3, 1) eq '2') then out = fix(arr(1)) return, out end ; if (item eq 'DMA') then begin arr = str2arr(value) ;comma separated out = strarr(4) + arr(n_elements(arr)-1) out(0) = arr return, out end ; message, 'Cannot decode the value. Value ='+value + ' Item: ' + item, /info err = err + 1 stop end ;---------------------------------------------------------- pro opsdb_uobs2obs, infil, outfil, id=id, lab_fil=lab_fil, flight=flight, sim=sim, qstop=qstop ; ;+ ;NAME: ; opsdb_uobs2obs ;PURPOSE: ; To translate the user's obs frame list to a pre-load format file. ;SAMPLE CALLING SEQUENCE: ; opsdb_uobs2obs, 'dt5x5_cal.uobs', /sim ; ff = findfile('/mdisw/cfl/comm/dep/*.uobs') ; for i=0,n_elements(ff)-1 do opsdb_uobs2obs, ff(i), /sim ;HISTORY: ; Written 9-Nov-95 by M.Morrison ; 5-Dec-95 (MDM) - Renamed from MDI_TRANS_UOBS to OPSDB_UOBS2OBS ; - Added ID keyword input ;- ; if (n_elements(lab_fil) eq 0) then begin qflight = 1 ;the default is to assume it is for the flight system if (keyword_set(sim)) then qflight = 0 ; if (qflight) then ff = file_list('$MDI_OPS_IP_DEP', 'mdi_uobs.*') $ else ff = file_list('$MDI_OPS_IP_DEP', 'sim_uobs.*') if (ff(0) eq '') then begin print, 'No UOBS files found in $MDI_OPS_IP_DEP' return end lab_fil = ff(n_elements(ff)-1) ;take the last one by default print, 'Using label file: ' + lab_fil end ; ; if (n_elements(outfil) eq 0) then outfil = str_replace(infil, '.uobs', '.obs') if (infil eq outfil) then stop, 'Output equals input file -- would overwrite' ; if (not file_exist(infil)) then begin message, 'Input file does not exist: ' + infil, /info return end if (not file_exist(lab_fil)) then begin message, 'Label input file does not exist: ' + lab_fil, /info return end ; mat = rd_tfile(infil, nocomment='#') remtab, mat, mat ;remove tabs mat = strtrim(strcompress(mat),2) ss = where(mat ne '', nss) if (nss eq 0) then begin message, 'Input file is empty: ' + infil, /info return end mat = mat(ss) ; ;TODO - check that there is no extra junk - only 3 lines of header ; ;------------------------------ ; lab = rd_tfile(lab_fil, 3, delim=string(9b), nocomment='#') if (n_elements(lab(0,*)) le 2) then begin message, 'Label input file is empty: ' + lab_fil, /info return end lab = lab(*, 2:*) ;drop the header and dash lines ; ;------------------------------ ; head = {name: ' ', descr: ' ', n: 0, id: 0, ip_prog: ' ', ip_addr: 0} image0 = {time: 0, mtm1: 0, mtm2: 0, cal1: 0, cal2: 0, paw: 0, itype: 'x', exp: 0, $ ofp: 0, dma: strarr(4)} ; p = strpos(mat(0), ':') & head.name = strtrim(strmid(mat(0), p+1, 999),2) p = strpos(mat(1), ':') & head.descr = strtrim(strmid(mat(1), p+1, 999),2) p = strpos(mat(2), ':') & head.ip_prog = strtrim(strmid(mat(2), p+1, 999),2) if (keyword_set(id)) then head.id = id ; n = n_elements(mat)-3 ;other than the 3 lines of header, the rest are images head.n = n ip_info = opsdb_get_info(label='QPROG_' + head.ip_prog, /active) if (data_type(ip_info) ne 8) then begin print, '*********** IP Queue Program Name Not Recognized. print, 'User input is: ' + head.ip_prog ip_info = opsdb_get_info(type='QADR') if (data_type(ip_info) eq 8) then begin ss = where(strmid(ip_info.label, 0, 5) eq 'QPROG', nss) if (nss ne 0) then print, 'Possible program names are: ', strmid(ip_info(ss).label, 6, 99) end print, '************ Aborting return end else begin if (ip_info(0).index eq 0) then begin print, 'WARNING: Index Information for the IP Program is Null for ' + ip_info(0).label end else begin head.ip_addr = ip_info(0).index print, 'WARNING: Index Information for the IP Program is ' + strtrim(head.ip_addr,2) + ' for ' + ip_info(0).label end end ; image = replicate(image0, n) ; err = 0 for i=0,n-1 do begin arr = str2arr(mat(i+3), delim=' ') v1 = float(arr(1))*16 if (i eq 0) then image0.time = v1 else image0.time = image(i-1).time + v1 image0.mtm1 = decode_trans_obs(arr(2), lab, 'MTM1', 1, err) image0.mtm2 = decode_trans_obs(arr(3), lab, 'MTM2', 1, err) image0.cal1 = decode_trans_obs(arr(4), lab, 'CAL1', 1, err) image0.cal2 = decode_trans_obs(arr(4), lab, 'CAL2', 1, err) image0.paw = decode_trans_obs(arr(5), lab, 'PAW', 1, err) image0.itype = decode_trans_obs(arr(6), lab, 'ITYPE', 0, err) image0.exp = decode_trans_obs(arr(7), lab, 'EXP', 1, err) image0.dma = decode_trans_obs(arr(8), lab, 'DMA', 0, err) ; if (image0.mtm1 lt 0) or (image0.mtm1 gt 179) then begin print, 'MTM1 Value is out of range. Needs to be from 0 to 179. print, 'User value = ' + arr(2) + ' which decodes to ' + strtrim(image0.mtm1,2) print, 'Aborting...' return end if (image0.mtm2 lt 0) or (image0.mtm2 gt 179) then begin print, 'MTM2 Value is out of range. Needs to be from 0 to 179. print, 'User value = ' + arr(2) + ' which decodes to ' + strtrim(image0.mtm2,2) print, 'Aborting...' return end ; image(i) = image0 end ; print, '-------------- Summary of Results for ' + infil + ' ------------- print, 'Start time of last image is: ', image0.time/16., ' seconds' print, 'Number of images: ', head.n print, ' ' ; ;------------------------------ Write it out ;;junk = ['CW', ' 1', 'CCW', ' 2', ' CW', ' 3', ' -', ' -'] ;shouldn't be needed.... junk = strarr(8)+'-' fmt1 = '(i3, ",", Z4.3, ",", i3, ",", 8(a4, ","), i4) fmt2 = '(i5,",", 5(i4, ","), a4, ",", i4, ",", i4, 4(",", a4))' openw, lun, outfil, /get_lun printf, lun, 'Name: ' + head.name + ' -- ' + head.descr printf, lun, ' Time CAL1 CAL2 PAW Dir IP printf, lun, ' N ID Fr1 Dir Pos Dir Pos Dir Pos M1 M2 Addr printf, lun, head.n, head.id, 80, junk, head.ip_addr, format=fmt1 printf, lun, ' ' printf, lun, ' MTM1 MTM2 CAL1 CAL2 PAW DMA printf, lun, ' Time Pos Pos Pos Pos Pos IType Exp OFP 0 1 2 3 for i=0,n-1 do printf, lun, image(i), format=fmt2 free_lun, lun if (keyword_set(qstop)) then stop end