;+ ; ; NAME: CPDISK ; ; PURPOSE: ; Read in a CP data file with housekeeping information and image ; ; CATEGORY: ; CP display ; ; CALLING SEQUENCE: ; CPDISK, DATA=DATA, HK=HOUSKEEP, FILE=FILENAME, OK=OK, $ ; IMSIZ=IMSIZ, SIN_MOV=SIN_MOV ; ; CALLED BY: ; CPDISPLAY ; ; CALLS TO: ; none ; ; INPUTS: ; FILENAME = Filename of CP data file to be read. ; SIN_MOV = 0 means current display mode is for single images ; 1 means current display mode is for movies ; ; OPTIONAL INPUTS: ; none ; ; OUTPUTS: ; DATA = Byte array of size equal to CP image in pixels. ; HK = Byte array of size equal to one dimension of image array. ; Contain CP housekeeping information, padded with zeroes ; OK = 0 means failed to successfully read the input file ; 1 means successfully read the input file ; IMSIZ = Size of one dimension of CP image, CP images are square. ; ; ; OPTIONAL OUTPUTS: ; none ; ; COMMON BLOCKS: ; CPWIDGBASES for widget IDs of informational output widgets. ; ; SIDE EFFECTS: ; none ; ; RESTRICTIONS: ; none ; ; PROCEDURE: ; Locate and open direct access data file. The total size in bytes, ; minus the header, squared is the size of the CP image in pixels. ; A VMS record length in multiples of 512 was tested for CPTAPE.PRO, ; but not implemented. Code for that option remains in these routine. ; ; MODIFICATION HISORY: ; 1991 - Elaine Einfalt (HSTX) ; ;- pro cpdisk, data=data, hk=houskeep, file=filename, ok=ok, $ imsiz=imsiz, sin_mov=sin_mov @cpwidgbases.common if strlen(filename(0)) eq 0 then filename='no_file_entered' a=findfile(filename) ok = 0 ; assume it will fail if a(0) eq '' then begin explain = 'No file found: ' + filename +' in CPDISK' if sin_mov eq 0 then widget_control, comment, set_value=explain, /append $ else widget_control, news, set_value=explain, /append return & endif on_ioerror, BADREAD openr,unit,filename,/get_lun status = fstat(unit) & imsiz = fix(sqrt(status.size)) ; file size ; if not one of the valid C/P data file sizes ; ex: 229888 = (448 lines data + 1 line header) * 512 record length ; or 201152 = (448 lines data + 1 line header) * 448 record length case status.size of 201152 : begin imsiz = 448 & recl = 448 & end 803712 : begin imsiz = 896 & recl = 896 & end 50400 : begin imsiz = 224 & recl = 224 & end 113232 : begin imsiz = 336 & recl = 336 & end 452256 : begin imsiz = 672 & recl = 672 & end 229888 : begin imsiz = 448 & recl = 512 & end 918528 : begin imsiz = 896 & recl = 1024 & end 115200 : begin imsiz = 224 & recl = 512 & end 172544 : begin imsiz = 336 & recl = 512 & end 344576 : begin imsiz = 672 & recl = 1024 & end else : return endcase w=assoc(unit, bytarr(recl,imsiz+1)) v = w(0) & houskeep = v(0:223) & data = v(*,1:imsiz) ok=1 ; success BADREAD: free_lun,unit return end