1  !   OUTPUT 2 USING "#,K";"<lf><lf>RE-STORE ""THRU""<cr>"
2  !
3   !1.0 -> 1.1 Fixed 5,8,9 in SUB Thru_init_icode,
4   !           FNMeas_file_spec$, and SUB Meas_do_cat.   Worked around disc
5   !           timeout problem by adding SUB Thru_wait_cntr.  Fixed 17 in
6   !           SUB Meas_init_file.
7     !
8   END
9     !
10    ! PAGE -> 
11    !***********************************************************************
12 Appl_appl:SUB Appl_appl
13      ! Used to declare all COMMON Blocks for "THRU", must be before all
14      ! "Appl_" or "Thru_" subprograms in file.
15    COM /Appl_data/ Data_buffer(1:9,0:8191),Data_header(1:9,1:10)
16    COM /Appl_disp/ Start_bin(1:9),Num_bins(1:9)
17    COM /Appl_buf_info/ Disp_choices$(1:63)[100],Disp_types$(1:2)[10],Num_inputs
18    COM /Appl_thru_parms/ Thru_length,Num_loops,Fallout_mode,Trigger_mode,Xfer_mode,Disc_addr,Disc_unit,Disc_vol
19    COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
20    COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
21    COM /Thru_disc_parms/ INTEGER Thruputacq_in(0:1267),Session_info(0:127),Disc_parm(0:1267)
22    COM /Thru_setup_parm/ Model_num$(1:63)[8],Ser_num$(1:63)[12],Module_label$(1:63)[40],Not_used$(1:63)[24],Setup$(1:63)[180],INTEGER Mod_addr(1:63)
23  SUBEND
24    !
25    ! PAGE -> 
26    !***********************************************************************
27 Appl_start:SUB Appl_start(Good_disc_data)
28    !
29    ! Called when a throughput is to be started.
30    !
31    !OUTPUT: Good_disc_data:  =1 when throughput successful (data on disc)
32    !
33    COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
34    COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
35    COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
36    COM /Appl_thru_parms/ Thru_length,Num_loops,Fallout_mode,Trigger_mode,Xfer_mode,Disc_addr,Disc_unit,Disc_vol
37    !
38    Thru_init_parm
39    Thru_do_thruput(Good_disc_data)
40    IF Good_disc_data THEN 
41      Thru_send_setup
42    END IF
43    !
44  SUBEND
45    !
46    ! PAGE -> 
47    !***********************************************************************
48 Appl_update:SUB Appl_update
49    ! This subprogram is call whenever the display configuration is changed.
50    ! Uses parms set up by the POST spreadsheet and through-put parameters
51    ! from the disc to update the DISP subprograms.
52    COM /Appl_data/ Data_buffer(*),Data_header(*)
53    COM /Appl_disp/ Start_bin(*),Num_bins(*)
54    COM /Appl_buf_info/ Disp_choices$(*),Disp_types$(*),Num_inputs
55      !
56    DISP "up-dating plot parameters"
57    Num_plots=FNDisp_num_plots
58    REDIM Start_bin(1:Num_plots)
59    REDIM Num_bins(1:Num_plots)
60    ALLOCATE Plot_to_buf(1:Num_plots)
61    ALLOCATE X_units$(1:Num_plots)[10],Y_units$(1:Num_plots)[10]
62    ALLOCATE Start_x(1:Num_plots),Per_bin_x(1:Num_plots)
63    ALLOCATE Y_def_max(1:Num_plots),Y_def_min(1:Num_plots)
64      !
65    Blk_size=FNThru_disc_parm("BLOCKSIZE")
66    Xfer_size=FNThru_disc_parm("XFER SIZE")
67    Loops=FNThru_disc_parm("SCANS")
68    Span=FNThru_sess_parm("SPAN")
69      !
70    Delta_t=.390625/Span
71    MAT Per_bin_x= (Delta_t)
72    MAT Start_bin= (0)
73    MAT Num_bins= (MIN(Blk_size,8192))
74     !MAT Num_bins= (MIN(Blk_size*Loops,8192))
75    FOR I=1 TO Num_plots
76      Plot_to_buf(I)=I
77      Trace_type_n=FNPost_tr_type(I)
78      Range=VAL(FNThru_setup_parm$("RANGE",Plot_to_buf(I)))
79      SELECT UPC$(Disp_types$(Trace_type_n))
80      CASE "TIME"
81        X_units$(I)="Secs"
82        Y_units$(I)="Volts"
83        Y_def_max(I)=10^((Range+2)/20)
84        Y_def_min(I)=-Y_def_max(I)
85        Data_header(I,2)=15094.3657/Y_def_max(I)   !SCALE FOR VALS IN DATA_BUFFER
86        Start_scan=FNThru_disc_parm("START SCAN",I)
87        Start_pt=FNThru_disc_parm("START POINT",I)
88        Start_x(I)=((Start_scan-1)*Xfer_size+(Start_pt-1))*Delta_t
89      CASE ELSE
90        User_stop("UNKNOWN PLOT TYPE IN Appl_update: "&Disp_types$(Trace_type_n))
91      END SELECT
92    NEXT I
93    Disp_plot_set(Plot_to_buf(*),X_units$(*),Y_units$(*),Start_x(*),Per_bin_x(*),Start_bin(*),Num_bins(*),Y_def_max(*),Y_def_min(*))
94    DISP ""
95  SUBEND
96    ! PAGE -> 
97    !***********************************************************************
98 Appl_init:SUB Appl_init
99      !
100     ! This subprogram is called whenever the hw configuration has changed
101     ! (That is, a change in active modules, or module labels in the
102     ! CNFG spreadsheet, or on power up.)  It initializes all modules and
103     ! their spreadsheets, values in the Measurement spreadsheet, and the
104     ! ICODE programs in the 35651A controller module.
105   COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
106   COM /Thru_setup_parm/ Model_num$(*),Ser_num$(*),Module_label$(*),Not_used$(*),Setup$(*),INTEGER Mod_addr(*)
107   COM /Appl_buf_info/ Disp_choices$(*),Disp_types$(*),Num_inputs
108   REM 
109     ! Init module spread sheets
110   DISP "Initializing modules and spread sheets"
111   Appl_powerup
112   DISP "Initializing through-put parameters"
113   Meas_init
114   Thru_init_hw
115   Thru_init_icode
116     !
117     ! get the available module names fromm configuration spread sheet
118   Cnfg_labels("ALL INPUT",Disp_choices$(*),Num_labels)   ! get active inputs
119     ! 1 type of plot for now
120   Num_types=1
121   Disp_types$(1)="Time"
122     ! setup Post module with titles
123   Post_spread_set(Disp_choices$(*),Num_labels,Disp_types$(*),Num_types)
124   Post_reset
125   Post_update_com
126   DISP 
127     !
128 SUBEND
129   ! PAGE -> 
130   !***********************************************************************
131 Thru_init_icode:SUB Thru_init_icode
132   !
133   ! Assembles and downloads the ICODE programs contained in the data
134   ! statements at the end of the subprogram. Should be called when
135   ! initializing the application.
136   ! The first ICODE program (starting at Thru_icode:) actually does
137   ! the through-puts to disc.
138   ! The second program is used to retrieve through-put data from
139   ! selected channels.  It starts at Read_disc:.
140   !
141   COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
142   COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
143   COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
144   INTEGER Parameter(1:16),List
145 !
146 ! COMPILE THROUGH-PUT ICODE
147!
148   ALLOCATE Source$(0:400)[100],Info$(1:1)[40],List$(0:0)[115]
149   ALLOCATE INTEGER Compiled(0:1023)
150   DISP "Assembling throughput Icode"
151   RESTORE Thru_icode
152   List=0
153   I=0
154   LOOP
155     READ Source$(I)
156   EXIT IF Source$(I)="EL_COMPLETO"
157     I=I+1
158   END LOOP
159   Num_err=FNIcode_assemble(Source$(*),Compiled(*),0,Info$(*),List,List$(*))
160   IF Num_err>0 THEN 
161     CALL User_error(VAL$(Num_err)&" ERRORS IN THRU_PUT ICODE")
162   END IF
163 !
164 ! DOWNLOAD ICODE
165 !
166   DISP "Downloading Throughput Icode program"
167   Hw_write_blk(Thru_icode_id,Compiled(*))
168  !
169  ! COMPILE DISC READ ICODE:
170  !
171   DISP "Assembling disc read Icode program"
172   RESTORE Read_disc
173   I=0
174   LOOP
175     READ Source$(I)
176   EXIT IF Source$(I)="EL_COMPLETO"
177     I=I+1
178   END LOOP
179   List=0
180   Num_err=FNIcode_assemble(Source$(*),Compiled(*),0,Info$(*),List,List$(*))
181   IF Num_err>0 THEN CALL User_error(VAL$(Num_err)&" ERRORS IN DISC READ ICODE")
182 !
183 ! DOWNLOAD ICODE
184 !
185   DISP "Downloading disc read Icode program"
186   Hw_write_blk(Read_icode_id,Compiled(*))
187 !
188   DISP ""
189   SUBEXIT
190     !
191 Thru_icode: ! THIS PROGRAM IS USED TO PERFORM THE THROUGH-PUTS TO DISC.
192   !
193! VARIABLES
194   DATA "      VAR HOST_HP_IB,0  !ADDRESS OF HOST COMPUTER"
195   DATA "      VAR DISC_HP_IB,0  !ADDRESS OF THROUGH-PUT DISC"
196   DATA "      VAR DISC_UNIT,0   !UNIT NUMBER OF THE DISC"
197   DATA "      VAR DISC_VOL,0    !VOLUME NUMBER."
198   DATA "      VAR LOOP_TO_DO,0  !NUMBER OF LOOPS OR SCANS WE WANT"
199   DATA "      VAR VALID_LOOP,0  !NUMBER OF LOOPS ACTUALLY DONE(RETURNED)"
200   DATA "      VAR EXTRA_LOOPS,0 !EXTRA LOOPS FOR SAFETY IN CONT MODE"
201   DATA "      VAR ADDR_BLOCK,0  !OFFSET OF DISC SEG ADDRESSES IN PARMS"
202   DATA "      VAR MOD_LIST,0    !OFFSET OF MODULE ADDRESSES IN PARMS"
203   DATA "      VAR MOD1,0        !FIRST MODULE IN MOD LIST   sw"
204   DATA "      VAR MOD1_O,0      !OFFSET IN MODLIST TO FIND MOD1   sw"
205   DATA "      VAR MOD_COUNT,0   !NUMBER OF MODULES TO THRUPUT FROM"
206   DATA "      VAR SAMPLE_MODE,0 !0=BLOCK 1=CONTINOUS"
207   DATA "      VAR SCAN_SIZE,0   !XFER_SIZE*MOD_COUNT"
208   DATA "      VAR LOOPS,0       !A LOOP COUNTER"
209   DATA "      VAR START_ADDR,0"   !DISC START_ADDR OF ICODE_PARM BLOCK
210   DATA "      VAR STATUS,0      !HOLDS STATUS REGISTER FROM MOD"
211   DATA "      VAR STATUS_BLOCK,0 !POINTS TO START OF STATUS INFO IN PARMS"
212   DATA "      VAR ERROR,0       !ERROR NUM"
213   DATA "      VAR FALLOUT,0     !0=ABORT 1=GOTO BLOCK MODE"
214   DATA "      VAR FO_DISC_SEG,0"
215   DATA "      VAR FO_LOOPS,0"
216   DATA "      VAR FO_DISC_ADDR,0"
217   DATA "      VAR OFFSET,0      !OFFSET POINTER"
218   DATA "      VAR SLOT,0        !MODULE POINTER"
219   DATA "      VAR LOPH,0        !HOLDS LOCAL OSCILLATOR PHASE FM MODULE"
220   DATA "      VAR DFPC,0        !HOLDS DIGITAL FILTER PHASE FROM MODULE"
221   DATA "      VAR I,0           !TEMPORARY STORAGE"
222   DATA "      VAR NEG1,-1       !A 'CONSTANT'"
223   DATA "      VAR THREE,3       !THE VALUE THREE,  sw"
224   DATA "      VAR TMP,0         !TEMP STORAGE"
225   DATA "      VAR SEG_CNT,0     !COUNTS DISC SEGMENTS"
226   DATA "      VAR TRIG_MODE,0   !HOLDS TRIG MODE (SEE CONST SECTION)"
227   DATA "      VAR THRU_PARM_LEN,0 !PORTION OF THRU_PARM TO WRITE TO DISC"
228! DEFBLOCKS
229   DATA "      DEFBLK_CON ICODE_BLOCKID,2 !BLOCK WHERE THIS PROG IS."
230   DATA "      DEFBLK_CON THRU_PARM,4     !PARAMETERS USED BY THIS PROG."
231   DATA "      DEFBLK_CON WORK,10         !USED FOR DUMMY SEGMENT TABLE"
232   DATA "                                 !ON FALL-THROUGH TO BLOCK MODE."
233 ! DEFINES OF VARIOUS CONSTANTS:
234 ! THESE POINT TO CORRESPONDING ITEMS IN THE THRU_PARM BLOCK:
235   DATA "      CONST HOST_HP_IB_O,0"
236   DATA "      CONST DISC_HP_IB_O,1"
237   DATA "      CONST DISC_UNIT_O,2"
238   DATA "      CONST DISC_VOL_O,3"
239   DATA "      CONST LOOP_TO_DO_O,4"
240   DATA "      CONST LOOP_TO_DO_L,5"
241   DATA "      CONST EXTRA_LOOPS_O,6"
242   DATA "      CONST SAMPLE_MODE_O,7"
243   DATA "      CONST SCAN_SIZE_O,8"
244   DATA "      CONST SCAN_SIZE_L,9"
245   DATA "      CONST FALLOUT_O,10"
246   DATA "      CONST TRIG_MODE_O,11"
247   DATA "      CONST STATUS_BLOCK_O,12"
248   DATA "      CONST ADDR_BLOCK_O,13"
249   DATA "      CONST MOD_LIST_O,14"
250   DATA "      CONST PLOT_INFO_O,15"
251   DATA "      CONST FILE_START_O,16"
252   DATA "      CONST FILE_START_L,17"
253  !
254  !OTHER CONSTANTS:
255   DATA "      CONST INPUT_MODULES,2   !INPUT MOD GLOBAL CLASS"
256  !XFER MODES:
257   DATA "      CONST BLOCK,0"
258   DATA "      CONST CONTINOUS,1"
259  !FALLOUT MODES:
260   DATA "      CONST ABORT,0"
261   DATA "      CONST GO_TO_BLOCK,1"
262  !TRIGGER MODES:
263   DATA "      CONST FREERUN,1"
264   DATA "      CONST ONCE,2"
265   DATA "      CONST EVERYTIME,3"
266     !
267 !  GET PARAMETERS:
268 Init: !
269   DATA "INIT: V_GET16_INDEXED THRU_PARM,HOST_HP_IB_O,HOST_HP_IB"
270   DATA "      V_GET16_INDEXED THRU_PARM,DISC_HP_IB_O,DISC_HP_IB"
271   DATA "      V_GET16_INDEXED THRU_PARM,DISC_UNIT_O,DISC_UNIT"
272   DATA "      V_GET16_INDEXED THRU_PARM,DISC_VOL_O,DISC_VOL"
273   DATA "      V_GET32_INDEXED THRU_PARM,LOOP_TO_DO_O,LOOP_TO_DO"
274   DATA "      V_GET16_INDEXED THRU_PARM,EXTRA_LOOPS_O,EXTRA_LOOPS"
275   DATA "      V_GET16_INDEXED THRU_PARM,SAMPLE_MODE_O,SAMPLE_MODE"
276   DATA "      V_GET16_INDEXED THRU_PARM,FALLOUT_O,FALLOUT"
277   DATA "      V_GET16_INDEXED THRU_PARM,TRIG_MODE_O,TRIG_MODE"
278   DATA "      V_GET16_INDEXED THRU_PARM,ADDR_BLOCK_O,ADDR_BLOCK"
279   DATA "      V_GET16_INDEXED THRU_PARM,STATUS_BLOCK_O,STATUS_BLOCK"
280   DATA "      V_GET16_INDEXED THRU_PARM,MOD_LIST_O,MOD_LIST"
281 ! TO FIND THE SLOT NUMBER OF THE FIRST MODULE, LOOK AT OFFSET 3 IN THE MOD_LIST
282   DATA "      V_ADD    MOD_LIST,THREE,MOD1_O "
283   DATA "      V_GET16_INDEXED THRU_PARM,MOD1_O,MOD1"
284   DATA "      V_GET32_INDEXED THRU_PARM,SCAN_SIZE_O,SCAN_SIZE"
285   DATA "      V_GET32_INDEXED THRU_PARM,FILE_START_O,START_ADDR"
286   DATA "      V_GET16_INDEXED THRU_PARM,PLOT_INFO_O,THRU_PARM_LEN"
287     !
288   DATA "      F_GLB_COMMAND INPUT_MODULES,'AZSM ON'"
289     !
290   DATA "      F_GLB_COMMAND INPUT_MODULES,'TSRC INP'"          ! sw
291   DATA "      C_BEQ FRRN,TRIG_MODE,FREERUN"                    ! sw
292   DATA "NEXT: C_NOP"
293   !
294   DATA "      C_BEQ CONT,SAMPLE_MODE,CONTINOUS"
295 !
296 ! STRICTLY BLOCK MODE TRANSFERS:
297   DATA "BLOCK:C_NOP"
298   DATA "      F_MOD_COMMAND MOD1,'RQS 2048'"
299   DATA "      F_GLB_COMMAND INPUT_MODULES,'INTR 8192'"
300   DATA "      F_GLB_COMMAND INPUT_MODULES,'TRNM BLK'"
301   !
302   DATA "      C_BEQ FREE,TRIG_MODE,FREERUN"                   !sw
303   DATA "      C_BEQ ONCE,TRIG_MODE,ONCE"                      !sw
304   !
305 ! DO TRIGGERED TRANSFER:
306   DATA "EVERY: C_NOP"
307   DATA "      F_ASSERT_TRIG"
308   DATA "      F_GLB_COMMAND INPUT_MODULES,'STRT'"
309   DATA "      C_GOSUB RDY?"
310   DATA "      F_SYNC"
311   DATA "      F_REQUEST_BUS"
312   DATA "      F_READY_DISC 1,HOST_HP_IB,DISC_HP_IB,DISC_UNIT,DISC_VOL"
313   DATA ".                  THRU_PARM,ADDR_BLOCK,THRU_PARM,MOD_LIST"
314   DATA ".                  VALID_LOOP"
315   DATA "      F_UNASSERT_TRIG"
316   DATA "      F_THRUPUT 1,1"
317   DATA "      F_RELEASE_BUS HOST_HP_IB"
318   DATA "      F_SIGNAL NEG1"
319   DATA "      F_GLB_COMMAND INPUT_MODULES,'STOP'"
320   DATA "      C_GOSUB STAT"
321   DATA "      C_GOTO DONE"
322   !
323     !
324 ! TRIGGER ONLY ON FIRST LOOP:
325   DATA "ONCE: C_BEQ FREE,TRIG_MODE,FREERUN"                   !sw
326     !
327   DATA "      F_ASSERT_TRIG"
328   DATA "      F_GLB_COMMAND INPUT_MODULES,'STRT'"
329   DATA "      C_GOSUB RDY?"
330   DATA "      F_SYNC"
331 ! SET UP SEG LIST FOR SECOND THRUPUT.
332   DATA "      V_VEQUATE ADDR_BLOCK,I           ! GET OFFSET TO SEGMENT LIST"
333   DATA "      V_CEQUATE 1,TMP                  ! 1 DISC SEGMENT"
334   DATA "      V_PUT16_INDEXED WORK,0,TMP       ! 1ST SEGMENT LIST SEGMENT COUNT"
335   DATA "      V_PUT16_INDEXED WORK,5,TMP       ! 2ND SEGMENT LIST SEGMENT COUNT"
336   DATA "      V_PUT32_INDEXED WORK,1,TMP       ! ONLY 1 LOOP IN 1ST SEGMENT LIST"
337   DATA "      V_ADD I,1,I                      ! OFFSET TO # OF LOOPS"
338   DATA "      V_GET32_INDEXED THRU_PARM,I,TMP  ! GET # OF LOOPS"
339   DATA "      V_SUB TMP,1,TMP                  ! SUBTRACT ONE TO USE IN 2ND SEGMENT"
340   DATA "      V_PUT32_INDEXED WORK,6,TMP       ! COPY # OF LOOPS FOR 2ND SEGMENT  LIST"
341   DATA "      V_ADD 2,I,I                      ! OFFSET TO STARTING ADDRESS"
342   DATA "      V_GET32_INDEXED THRU_PARM,I,TMP  ! GET STARTING ADDRESS"
343   DATA "      V_PUT32_INDEXED WORK,3,TMP       ! COPY STARTING ADDRESS"
344   DATA "      V_ADD TMP,SCAN_SIZE,TMP          ! ADD SCAN SIZE TO STARTING ADDRESS"
345   DATA "      V_PUT32_INDEXED WORK,8,TMP       ! COPY STARTING ADDR+SCAN SIZE TO 2ND LIST"
346 !
347 ! NOW START THRUPUT, WAITING FOR TRIGGER ON FIRST BLOCK
348   DATA "      F_REQUEST_BUS"
349   DATA "      F_READY_DISC 1,HOST_HP_IB,DISC_HP_IB,DISC_UNIT,DISC_VOL"
350   DATA ".                  WORK,0,THRU_PARM,MOD_LIST"
351   DATA ".                  VALID_LOOP"
352   DATA "      F_UNASSERT_TRIG"
353   DATA "      F_THRUPUT 1,1"
354   DATA "      F_ASSERT_TRIG"
355   DATA "      C_GOSUB STAT"
356     !TURN OFF THE TRIGGERING FOR THE REST OF THE DATA:"
357   DATA "      F_GLB_COMMAND INPUT_MODULES,'TSRC FREE'"
358   DATA "      F_GLB_COMMAND INPUT_MODULES,'STRT'"
359   DATA "      C_GOSUB RDY?"
360   DATA "      F_SYNC"
361   DATA "      F_READY_DISC 1,HOST_HP_IB,DISC_HP_IB,DISC_UNIT,DISC_VOL"
362   DATA ".                  WORK,5,THRU_PARM,MOD_LIST"
363   DATA ".                  VALID_LOOP"
364   DATA "      F_UNASSERT_TRIG"
365   DATA "      F_THRUPUT 1,1"
366   DATA "      F_RELEASE_BUS HOST_HP_IB"
367   DATA "      F_SIGNAL NEG1"
368   DATA "      F_GLB_COMMAND INPUT_MODULES,'STOP'"
369   DATA "      C_GOSUB STAT"
370   DATA "      C_GOTO DONE"
371     !
372  ! FREE RUN, BLOCK MODE:
373   DATA "FREE: C_NOP"
374   DATA "      F_ASSERT_TRIG"
375   DATA "      F_GLB_COMMAND INPUT_MODULES,'STRT'"
376   DATA "      C_GOSUB RDY?"
377   DATA "      F_SYNC"
378   DATA "      F_REQUEST_BUS"
379   DATA "      F_READY_DISC 1,HOST_HP_IB,DISC_HP_IB,DISC_UNIT,DISC_VOL"
380   DATA ".                  THRU_PARM,ADDR_BLOCK,THRU_PARM,MOD_LIST"
381   DATA ".                  VALID_LOOP"
382   DATA "      F_UNASSERT_TRIG"
383   DATA "      F_THRUPUT 1,1"
384   DATA "      F_RELEASE_BUS HOST_HP_IB"
385   DATA "      F_SIGNAL NEG1"
386   DATA "      F_GLB_COMMAND INPUT_MODULES,'STOP'"
387   DATA "      C_GOSUB STAT                 ! WRITE INPUT MODULE STATUS"
388   DATA "      C_GOTO DONE"
389     !
390 ! CONTINUOUS MODE:
391   DATA "CONT: C_NOP"
392   DATA "      F_GLB_COMMAND INPUT_MODULES,'RQS 2048'"
393   DATA "      F_GLB_COMMAND INPUT_MODULES,'INTR 8192'"
394   DATA "      F_GLB_COMMAND INPUT_MODULES,'TRNM CONT'"
395   DATA "      F_ASSERT_TRIG"
396   DATA "      F_GLB_COMMAND INPUT_MODULES,'STRT'"
397   DATA "      C_GOSUB RDY?"
398   DATA "      F_SYNC"
399   DATA "      F_REQUEST_BUS"
400   DATA "      F_READY_DISC 1,HOST_HP_IB,DISC_HP_IB,DISC_UNIT,DISC_VOL"
401   DATA ".                  THRU_PARM,ADDR_BLOCK,THRU_PARM,MOD_LIST"
402   DATA ".                  VALID_LOOP"
403   DATA "      F_UNASSERT_TRIG"
404   DATA "      F_THRUPUT 1,1"
405   DATA "      F_RELEASE_BUS HOST_HP_IB"
406   DATA "      F_GLB_COMMAND INPUT_MODULES,'STOP'"
407   DATA "      V_ADD LOOP_TO_DO,EXTRA_LOOPS,LOOPS"
408   DATA "      C_BNE TOBLK,VALID_LOOP,LOOPS"
409   DATA "      F_SIGNAL NEG1"
410   DATA "      V_SUB VALID_LOOP,EXTRA_LOOPS,VALID_LOOP   !CHANGE VALID LOOP TO RIGHT NUMBER"
411   DATA "      V_VEQUATE STATUS_BLOCK,OFFSET             !GET OFFSET TO STATUS BLOCK"
412   DATA "      V_ADD 2,OFFSET,OFFSET                     !OFFSET TO REALTIME SCANS"
413   DATA "      V_PUT32_INDEXED THRU_PARM,OFFSET,VALID_LOOP  !WRITE NUMBER OF REALTIME LOOPS"
414   DATA "      C_GOSUB STAT                      !WRITE INPUT MODULE STATUS"
415   DATA "      C_GOTO DONE"
416     !
417 ! CREATE A SEGMENT LIST FOR THE REST OF THE DATA.
418   DATA "TOBLK:"
419   DATA "      V_SUB VALID_LOOP,EXTRA_LOOPS,VALID_LOOP   !SUBRTRACT EXTRA LOOPS TO GET TRUE VALID LOOPS"
420   DATA "      C_BGE POS,VALID_LOOP,0                    !MAKE SURE GREATER THAN ZERO"
421   DATA "      V_CEQUATE 0,VALID_LOOP                    !IF NOT SET TO ZERO"
422   DATA "POS:  F_SIGNAL VALID_LOOP                       !SIGNAL HOST NUMBER OF VALID LOOPS >=0"
423   DATA "      V_VEQUATE STATUS_BLOCK,OFFSET             !GET OFFSET TO STATUS BLOCK"
424   DATA "      V_ADD 2,OFFSET,OFFSET                     !OFFSET TO REALTIME SCANS"
425   DATA "      V_PUT32_INDEXED THRU_PARM,OFFSET,VALID_LOOP  !WRITE NUMBER OF REALTIME LOOPS"
426   DATA "      C_BEQ DOBLK,FALLOUT,GO_TO_BLOCK           !SEE IF WE WANT TO GOTO BLOCK MODE"
427   DATA "      C_GOSUB STAT                             !IF NOT WRITE STATUS"
428   DATA "      C_GOTO DONE                              ! AND RETURN"
429   DATA "DOBLK:"
430   DATA "      V_VEQUATE VALID_LOOP,LOOPS               !COPY VALID_LOOPS INTO LOOPS"
431   DATA "      V_VEQUATE ADDR_BLOCK,I                   !GET DISC SEGMENT TABLE"
432   DATA "      V_SUB I,3,I                              !SUBTRACT 3 TO GET TO 1ST LOOP"
433   DATA "      V_CEQUATE 0,SEG_CNT"
434     !""
435   DATA "LP1:  V_ADD I,4,I                             !OFFSET TO NEXT LOOP COUNT"
436   DATA "      V_ADD 1,SEG_CNT,SEG_CNT"
437   DATA "      V_GET32_INDEXED THRU_PARM,I,FO_LOOPS    !GET CURRENT NUMBER OF DISC LOOPS"
438   DATA "      V_SUB LOOPS,FO_LOOPS,LOOPS              !SUBTRACT SEGMENT LOOPS FROM LOOPS"
439   DATA "      C_BGT LP1,LOOPS,0                       !IF GREATER THAN ZERO, GOTO NEXT LOOP"
440     !
441   DATA "      V_SUB 0,LOOPS,LOOPS"                      !MAKE POSITIVE
442   DATA "      V_SUB FO_LOOPS,LOOPS,FO_LOOPS"
443   DATA "      C_BEQ LP2,0,FO_LOOPS"      ! IF ZERO DON'T MAKE A NEW SEGMENT
444   DATA "      V_PUT32_INDEXED THRU_PARM,I,FO_LOOPS"     !UPDATE OLD SEGMENT LOOP COUNTER
445   DATA "      V_ADD I,2,I"
446   DATA "      V_GET32_INDEXED THRU_PARM,I,FO_DISC_ADDR"
447   DATA "      V_MULT FO_LOOPS,SCAN_SIZE,SCAN_SIZE"
448   DATA "      V_ADD FO_DISC_ADDR,SCAN_SIZE,FO_DISC_ADDR"
449   DATA "      V_ADD 1,SEG_CNT,SEG_CNT"
450   DATA "      V_ADD I,2,I"
451   DATA "      C_GOTO JMP1"
452     !
453   DATA "LP2:  V_ADD I,2,I"
454   DATA "      V_GET32_INDEXED THRU_PARM,I,FO_DISC_ADDR"
455   DATA "      V_SUB I,2,I"
456     !
457   DATA "JMP1: V_SUB LOOP_TO_DO,VALID_LOOP,FO_LOOPS"
458   DATA "      V_PUT32_INDEXED THRU_PARM,I,FO_LOOPS"
459   DATA "      V_ADD I,2,I"
460   DATA "      V_PUT32_INDEXED THRU_PARM,I,FO_DISC_ADDR"
461   DATA "      V_ADD I,2,I"
462   DATA "      V_CEQUATE -1,LOOPS"
463   DATA "      V_PUT32_INDEXED THRU_PARM,I,LOOPS"
464   DATA "      V_ADD I,2,I"
465   DATA "      V_PUT32_INDEXED THRU_PARM,I,LOOPS"
466     !
467   DATA "RSTRT:"
468   DATA "      V_VEQUATE ADDR_BLOCK,I                   !GET DISC SEGMENT TABLE"
469   DATA "      V_PUT16_INDEXED THRU_PARM,I,SEG_CNT      !RE-WRITE UPDATED SEGMENT COUNT"
470   DATA "      V_CEQUATE 1,LOOPS                        !ONLY 1 DISC SEGMENT"
471   DATA "      V_PUT16_INDEXED WORK,0,LOOPS             !WRITE # OF DISC SEGMENTS"
472   DATA "      V_PUT32_INDEXED WORK,1,FO_LOOPS          !WRITE # OF FALLOUT LOOPS"
473   DATA "      V_PUT32_INDEXED WORK,3,FO_DISC_ADDR      !WRITE FALLOUT DISC ADDRESS"
474 ! NOW GET" THE REST OF THE DATA, IN BLOCK MODE."
475   DATA "      F_GLB_COMMAND INPUT_MODULES,'TRNM BLK;'       !CHANGE TRANSFER MODE TO BLOCK"
476   DATA "      F_ASSERT_TRIG"
477   DATA "      F_GLB_COMMAND INPUT_MODULES,'STRT;'"
478   DATA "      C_GOSUB RDY?"
479   DATA "      F_SYNC"
480   DATA "      F_REQUEST_BUS"
481   DATA "      F_READY_DISC 0,HOST_HP_IB,DISC_HP_IB,DISC_UNIT,DISC_VOL"
482   DATA ".                  WORK,0,THRU_PARM,MOD_LIST"
483   DATA ".                  VALID_LOOP"
484   DATA "      F_UNASSERT_TRIG"
485   DATA "      F_THRUPUT 1,1"
486   DATA "      F_RELEASE_BUS HOST_HP_IB"
487   DATA "      F_GLB_COMMAND INPUT_MODULES,'STOP;'"
488   DATA "      V_VEQUATE LOOP_TO_DO,VALID_LOOP"
489   DATA "      C_GOSUB STAT"
490   DATA "      C_GOTO DONE"
491     !
492     ! COME HERE AFTER THRUPUT TO SAVE STATUS INFO ON DISC
493   DATA "DONE: C_NOP"
494   DATA "      F_REQUEST_BUS"
495   DATA "      F_WRITE_DISC THRU_PARM,0,THRU_PARM_LEN,0,THRU_PARM_LEN"
496   DATA ".            DISC_HP_IB,DISC_UNIT,DISC_VOL,START_ADDR"
497   DATA "      F_RELEASE_BUS HOST_HP_IB"
498   DATA "      C_END"
499     !
500     ! SUBROUTINE TO WRITE STATUS OF INPUT_MODULES IN THE MODULE LIST
501     !
502   DATA "STAT: V_VEQUATE STATUS_BLOCK,OFFSET        !GET OFFSET TO STATUS BLOCK"
503   DATA "      V_PUT32_INDEXED THRU_PARM,OFFSET,VALID_LOOP !WRITE TOTAL NUMBER OF VALID LOOPS"
504   DATA "      V_ADD 8,OFFSET,OFFSET                !INCREMENT OFFSET TO POINT TO OVERLOAD #1"
505   DATA "      V_VEQUATE MOD_LIST,I                 !GET START OF MODULE LIST"
506   DATA "      V_ADD 2,I,I                          !OFFSET IN TO LIST TO POINT TO MODULE COUNT"
507   DATA "      V_GET16_INDEXED THRU_PARM,I,MOD_COUNT !COPY IT INTO MOD_COUNT VARIABLE"
508   DATA "      V_ADD 1,I,I                       !ADD 1 TO OFFSET TO POINT TO 1ST MODULE"
509   DATA "      V_ADD I,MOD_COUNT,MOD_COUNT       !ADD MOD_COUNT AND I TO DETERMINE END OF LOOP"
510   DATA "LOOP1:C_NOP"
511   DATA "      V_GET16_INDEXED THRU_PARM,I,SLOT  !GET THE SLOT POINTED TO BY I"
512   DATA "      F_GET_STATUS SLOT,STATUS          !READ STATUS REGISTER FOR MODULE IN 'SLOT'"
513   DATA "      V_AND STATUS,128,STATUS           !MASK THE OVERLOAD BIT"
514   DATA "      V_PUT32_INDEXED THRU_PARM,OFFSET,STATUS  !COPY OVERLOAD RESULT INTO STATUS BLOCK"
515   DATA "      V_ADD 2,OFFSET,OFFSET             !OFFSET DESTINATION"
516   DATA "      F_MOD_COMMAND SLOT,'LOPH?;'       !ASK FOR INPUT MODULE LO PHASE"
517   DATA "      F_GET_ASCII SLOT,1,LOPH           !READ INPUT MODULE LO PHASE"
518   DATA "      V_PUT32_INDEXED THRU_PARM,OFFSET,LOPH  !COPY LO PHASE INTO STATUS BLOCK"
519   DATA "      V_ADD 2,OFFSET,OFFSET             !OFFSET DESTINATION"
520   DATA "      F_MOD_COMMAND SLOT,'DFPC?;'       !ASK FOR INPUT MODULE DF PHASE CORRECTION"
521   DATA "      F_GET_ASCII SLOT,1,DFPC           !READ DF PHASE CORRECTION"
522   DATA "      V_PUT32_INDEXED THRU_PARM,OFFSET,DFPC   !COPY DF PHASE CORRECTION INTO STATUS BLOCK"
523   DATA "      V_ADD 4,OFFSET,OFFSET             !OFFSET DESTINATION TO NEXT SLOT ENTRY"
524   DATA "      V_ADD 1,I,I                       !UPDATE MODULE TABLE OFFSET"
525   DATA "      C_BNE LOOP1,I,MOD_COUNT           !SEE IF END OF TABLE"
526   DATA "      C_RTS"
527     !
528     ! SUBROUTINE TO SEE IF ALL INPUT MODULES ARE READY TO SYNC
529     !
530   DATA "RDY?: F_GET_GBL_STA STATUS"
531   DATA "      V_NOT STATUS,STATUS"
532   DATA "      C_BITSET RDY?,STATUS,4"
533   DATA "      C_RTS"
534     !
535     ! SIDE TRIP TO CHANGE TRIGGER MODE TO SYSTEM FREE RUN      !sw
536   DATA "FRRN: C_NOP"                                           !sw
537   DATA "      F_GLB_COMMAND INPUT_MODULES,'TSRC FREE'"         !sw
538   DATA "      C_GOTO NEXT"                                     !sw
539   !
540   DATA  "EL_COMPLETO"
541   !
542   ! PAGE -> 
543   !***********************************************************************
544 Read_disc:   !
545   ! ICODE PROGRAM TO FETCH TIME DATA FROM DISC.
546   DATA "      VAR HOST_HP_IB,0  !ADDRESS OF HOST COMPUTER"
547   DATA "      VAR DISC_HP_IB,0  !ADDRESS OF THROUGH-PUT DISC"
548   DATA "      VAR DISC_UNIT,0   !DISC UNIT #"
549   DATA "      VAR DISC_VOL,0    !DISC VOL #"
550   DATA "      VAR SCAN_SIZE,0   !#OF BYTES PER THROUGH-PUT LOOP."
551   DATA "      VAR START_ADDR,0  !START ADDR OF CURRENT DISC SEGMENT."
552   DATA "      VAR TRACE_NUM,0   !COUNTER FOR THE TRACES"
553   DATA "      VAR SCAN_NUM,0    !COUNTER FOR THE PLOT SCAN"
554   DATA "      VAR SEG_NUM,0     !COUNTER FOR DISC SEGMENTS"
555     !FROM THE PLOT PARMS:
556   DATA "      VAR PLOT_NUM_SCANS,0 !TOTAL # OF PLOT BLOCKS TO GET"
557   DATA "      VAR PLOT_BLK_SIZE,0 !SIZE OF THE PLOT BLOCKS IN WORDS"
558   DATA "      VAR MOD_COUNT,0   !TOTAL #  MODULES IN THROUGH-PUT"
559   DATA "      VAR TOT_SEGS,0    !TOTAL DISC SEGMENTS USED"
560   DATA "      VAR START_SCAN,0  !# OF 1ST THRU-PUT SCAN TO RETURN"
561   DATA "      VAR START_POINT,0 !STARTING SAMPLE IN START_SCAN"
562   DATA "      VAR MOD_OFFSET,0  !ADDR OFFSET DUE TO MOD NUM"
563     !
564   DATA "      VAR XFER_SIZE,0   !SIZE OF THRUPUT TRANSFERS (W)"
565   DATA "      VAR LENGTH,0      !PLOT_BLK_SIZE*NUM_PLOTS"
566   DATA "      VAR NUM_LOOPS,0   !# LOOPS IN CURRENT DISC SEGMENT"
567   DATA "      VAR SCAN_OFFSET,0 !ADDR OFFSET TO ACCOUNT FOR CURRENT SCAN"
568   DATA "      VAR BLOCK_OFFSET,0 !ADDR OFFSET TO ACCOUNT FOR PLOT BLK"
569   DATA "      VAR TRACE_OFFSET,0 !ADDR OFFSET TO ACCOUNT FOR TRACE NUM"
570   DATA "      VAR SEG_OFFSET,0   !OFFSET FOR PTR TO SEG INFO"
571   DATA "      VAR LOOPS_PTR,0   !POINTS TO NUM_LOOPS FOR CURR SEG"
572   DATA "      VAR SEG_ADDR_PTR,0 !POINTS TO SEG ADDR IN THRU_PARM"
573   DATA "      VAR PP_PTR,0       !POINTS TO PLOT PARMS IN OLD_THRU_PARM"
574   DATA "      VAR NUM_SEG_PTR,0  !POINTS TO TOT_SEGS IN OLD_THRU_PARM"
575   DATA "      VAR PLOT_SCAN_PTR,0 !POINTS TO PLOT_NUM_SCANS"
576   DATA "      VAR BSIZE_PTR,0    !POINTS TO PLOT_BLK_SIZE"
577   DATA "      VAR MOD_CNT_PTR,0  !POINTS TO MOD_COUNT"
578   DATA "      VAR MOD_PLT_PTR,0  !POINTS TO PLOT DATA FOR 1ST MODULE"
579   DATA "      VAR SEG_INFO_PTR,0 !POINTS TO DISC SEGMENT INFO"
580   DATA "      VAR MINUS_ONE,-1   !A CONSTANT DISGUISED AS A VARIABLE"
581   DATA "      VAR TEMP,0         !TEMPORARY STORAGE"
582   DATA "      VAR MOD_LIST,0     !POINTS TO MODULE LIST IN OLD_THRU_PARM"
583   DATA "      VAR PLOT_WORD_CNT,0 !COUNTS NUM_WORDS TRANSFERRED FOR PLOT"
584   DATA "      VAR SEG_ERR,-2        !AN ERROR CODE"
585 ! DEFBLOCKS
586   DATA "      DEFBLK_CON ICODE_BLOCKID,2 !THE THROUGH-PUT PROG"
587   DATA "      DEFBLK_CON THRU_PARM,4     !PARMS FOR THROUGH-PUT PROG"
588   DATA "      DEFBLK_CON READ_ICODE,6    !THIS ICODE PROGRAM."
589   DATA "      DEFBLK_CON TIME_BUFFER,8   !WHERE THIS PROG PUTS DATA."
590   DATA "      DEFBLK_CON WORK,10         !USED BY THROUGH-PUT PROG"
591   DATA "      DEFBLK_CON OLD_THRU_PARM,12 !PARMS USED BY THIS PROG"
592 !
593 ! DEFINES  (POINTERS TO ITEMS IN THRUPUT PARM BLOCKS)
594   DATA "      CONST HOST_HP_IB_O,0"
595   DATA "      CONST DISC_HP_IB_O,1"
596   DATA "      CONST DISC_UNIT_O,2"
597   DATA "      CONST DISC_VOL_O,3"
598   DATA "      CONST SCAN_SIZE_O,8"
599   DATA "      CONST SCAN_SIZE_L,9"
600   DATA "      CONST STATUS_BLOCK_O,12 !ITEM 12 POINTS TO STATUS BLOCK"
601   DATA "      CONST ADDR_BLOCK_O,13   !ITEM 13 POINTS TO DISC ADDR BLK"
602   DATA "      CONST MOD_LIST_O,14     !ITEM 14 POINTS TO MODULE LIST BLK"
603   DATA "      CONST PLOT_PARM_O,15    !ITEM 15 POINTS TO PLOT PARM BLK"
604   !
605   DATA "      CONST F_GET_DEBUG_LVL,$8C"
606   DATA "      CONST F_SET_DEBUG_LVL,$8D"
607     !
608 ! PROGRAM
609 !  GET PARAMETERS FROM THRUPUT_PARM BLOCK:
610   DATA "INIT: V_GET16_INDEXED OLD_THRU_PARM,HOST_HP_IB_O,HOST_HP_IB"
611   DATA "      V_GET16_INDEXED OLD_THRU_PARM,DISC_HP_IB_O,DISC_HP_IB"
612   DATA "      V_GET16_INDEXED OLD_THRU_PARM,DISC_UNIT_O,DISC_UNIT"
613   DATA "      V_GET16_INDEXED OLD_THRU_PARM,DISC_VOL_O,DISC_VOL"
614   DATA "      V_GET32_INDEXED OLD_THRU_PARM,SCAN_SIZE_O,SCAN_SIZE"
615   DATA "      V_GET16_INDEXED OLD_THRU_PARM,MOD_LIST_O,MOD_LIST"
616   DATA "      V_GET16_INDEXED OLD_THRU_PARM,MOD_LIST,XFER_SIZE"
617   DATA "      V_GET16_INDEXED OLD_THRU_PARM,PLOT_PARM_O,PLOT_SCAN_PTR"
618   DATA "      V_GET16_INDEXED OLD_THRU_PARM,ADDR_BLOCK_O,NUM_SEG_PTR"
619     !
620     !CALC THE POINTERS TO THE PLOT_PARAMETERS IN OLD_THRU_PARM
621   DATA "      V_ADD 2,PLOT_SCAN_PTR,BSIZE_PTR"
622   DATA "      V_ADD 3,PLOT_SCAN_PTR,MOD_CNT_PTR"
623   DATA "      V_ADD 4,PLOT_SCAN_PTR,MOD_PLT_PTR"
624     !
625     !CALC THE POINTERS TO ADDR BLOCK ITEMS.
626   DATA "      V_ADD 1,NUM_SEG_PTR,SEG_INFO_PTR"
627     !
628     ! ALGORITHM OF PROGRAM:
629     !
630     ! RESTORE OLD_THRU_PARM
631     ! READ PLOT_NUM_SCANS,PLOT_BLK_SIZE,MOD_COUNT,TOT_SEGS
632     ! IF PLOT_BLK_SIZE>XFER_SIZE THEN !MUST READ IN XFER_SIZE CHUNKS OR LESS.
633     !   PLOT_NUM_SCANS=PLOT_NUM_SCAN*(PLOT_BLK_SIZE/XFER_SIZE)
634     !   PLOT_BLK_SIZE=XFER_SIZE
635     ! END IF
636     ! LENGTH=PLOT_NUM_SCANS*PLOT_BLK_SIZE
637     ! FOR SCAN_NUM=1 TO PLOT_NUM_SCANS
638     !   FOR TRACE_NUM=1 TO MOD_COUNT
639     !     PLOT_WORD_CNT=(SCAN_NUM-1) * PLOT_BLK_SIZE
640     !     TRACE_OFFSET=(TRACE_NUM-1)*4
641     !     BLOCK_OFFSET=PLOT_WORD_CNT+(TRACE_NUM-1)*LENGTH
642     !     PP_PTR=TRACE_OFFSET+MOD_PLT_PTR
643     !     READ@PP_PTR START_SCAN
644     !     PP_PTR=PP_PTR+2
645     !     READ@PP_PTR START_POINT
646     !     PLOT_WORD_CNT=PLOT_WORD_CNT+START_POINT-1
647     !     START_SCAN=(PLOT_WORD_CNT DIV XFER_SIZE)+START_SCAN-1
648     !     PP_PTR=PP_PTR+1
649     !     READ@PP_PTR MOD_OFFSET
650     !     MOD_OFFSET=MOD_OFFSET-1
651     !     SEG_NUM=0
652     !     LOOP
653     !       SEG_OFFSET=4*SEG_NUM
654     !       LOOPS_PTR=SEG_OFFSET+SEG_INFO_PTR
655     !       SEG_NUM=SEG_NUM+1
656     !       IF SEG_NUM > TOT_SEGS THEN GOTO ERR1
657     !       READ@LOOPS_PTR NUM_LOOPS
658     !     EXIT IF START_SCAN<NUM_LOOPS
659     !       START_SCAN=START_SCAN-NUM_LOOPS
660     !     END LOOP
661     !     SEG_ADDR_PTR=2+LOOPS_PTR
662     !     READ@SEG_ADDR_PTR START_ADDR
663     !     START_ADDR=START_ADDR + 2*(PLOT_WORD_CNT MOD XFER_SIZE)
664     !     SCAN_OFFSET=SCAN_SIZE*START_SCAN
665     !     MOD_OFFSET=2*(XFER_SIZE*MOD_OFFSET)
666     !     START_ADDR=START_ADDR+SCAN_OFFSET+MOD_OFFSET
667     !     (READ DISC@START_ADDR TO TIME_BUFFER@BLOCK_OFFSET)
668     !   NEXT TRACE_NUM
669     ! NEXT SCAN_NUM
670     ! SIGNAL -1
671     ! END
672     !
673   DATA "BEGIN:"
674     !FETCH THE GLOBAL PARMS:
675   DATA "      V_GET32_INDEXED OLD_THRU_PARM,PLOT_SCAN_PTR,PLOT_NUM_SCANS"
676   DATA "      V_GET16_INDEXED OLD_THRU_PARM,BSIZE_PTR,PLOT_BLK_SIZE"
677   DATA "      V_GET16_INDEXED OLD_THRU_PARM,MOD_CNT_PTR,MOD_COUNT"
678   DATA "      V_GET16_INDEXED OLD_THRU_PARM,NUM_SEG_PTR,TOT_SEGS"
679   DATA "      C_BLE OKAY,PLOT_BLK_SIZE,XFER_SIZE"
680   DATA "        V_DIV PLOT_BLK_SIZE,XFER_SIZE,TEMP"
681   DATA "        V_MULT PLOT_NUM_SCANS,TEMP,PLOT_NUM_SCANS"
682   DATA "        V_VEQUATE XFER_SIZE,PLOT_BLK_SIZE"
683   DATA "OKAY: V_MULT PLOT_BLK_SIZE,PLOT_NUM_SCANS,LENGTH"
684     !""
685   DATA "      V_CEQUATE 0,SCAN_NUM"
686   DATA "      F_REQUEST_BUS"
687   DATA "NEXTS:               !FOR SCAN_NUM=1 TO PLOT_NUM_SCANS"
688   DATA "        V_ADD 1,SCAN_NUM,SCAN_NUM"
689   DATA "        V_CEQUATE 0,TRACE_NUM"
690   DATA "NEXTT:         !FOR TRACE_NUM=1 TO MOD_COUNT"
691  !GET THE NEEDED INFO FROM THE PLOT_PARAMETER STUFF IN OLD_THRU_PARM.
692   DATA "          V_SUB SCAN_NUM,1,TEMP"
693   DATA "          V_MULT TEMP,PLOT_BLK_SIZE,PLOT_WORD_CNT"
694   DATA "          V_MULT 4,TRACE_NUM,TRACE_OFFSET"
695   DATA "          V_MULT LENGTH,TRACE_NUM,TEMP"
696   DATA "          V_ADD TEMP,PLOT_WORD_CNT,BLOCK_OFFSET"
697   DATA "          V_ADD 1,TRACE_NUM,TRACE_NUM"
698   DATA "          V_ADD TRACE_OFFSET,MOD_PLT_PTR,PP_PTR !PTR TO START_SCAN"
699   DATA "          V_GET32_INDEXED OLD_THRU_PARM,PP_PTR,START_SCAN"
700   DATA "          V_ADD 2,PP_PTR,PP_PTR"
701   DATA "          V_GET16_INDEXED OLD_THRU_PARM,PP_PTR,START_POINT"
702   DATA "          V_SUB START_POINT,1,START_POINT !WANT OFFSET"
703   DATA "          V_ADD START_POINT,PLOT_WORD_CNT,PLOT_WORD_CNT"
704   DATA "          V_DIV PLOT_WORD_CNT,XFER_SIZE,TEMP  !PLOT-SCAN OFFSET"
705   DATA "          V_ADD TEMP,START_SCAN,START_SCAN"
706   DATA "          V_SUB START_SCAN,1,START_SCAN  !WANT OFFSET, NOT NUM."
707   DATA "          V_ADD 1,PP_PTR,PP_PTR"
708   DATA "          V_GET16_INDEXED OLD_THRU_PARM,PP_PTR,MOD_OFFSET"
709   DATA "          V_SUB MOD_OFFSET,1,MOD_OFFSET  !WANT OFFSET, NOT NUM."
710     !
711     !SEARCH THROUGH THE SEGMENT TABLE FOR THE START OF THE SCAN WE WANT.
712   DATA "          V_CEQUATE 0,SEG_NUM"
713   DATA "  LOOP:"
714     !CALC THE POINTERS TO THE SEGMENT INFO.
715   DATA "            V_MULT 4,SEG_NUM,SEG_OFFSET"
716   DATA "            V_ADD SEG_OFFSET,SEG_INFO_PTR,LOOPS_PTR"
717   DATA "            V_ADD 1,SEG_NUM,SEG_NUM"
718     ! AN ERROR CHECK.
719   DATA "            C_BGT ERR1,SEG_NUM,TOT_SEGS"
720   DATA "            V_GET32_INDEXED OLD_THRU_PARM,LOOPS_PTR,NUM_LOOPS"
721   DATA "            C_BLT GOTIT,START_SCAN,NUM_LOOPS"
722   DATA "            V_SUB START_SCAN,NUM_LOOPS,START_SCAN"
723   DATA "          C_GOTO LOOP"
724     !FOUND THE SCAN!, GET THE ADDR:
725   DATA "GOTIT:"
726   DATA "          V_ADD 2,LOOPS_PTR,SEG_ADDR_PTR"
727   DATA "          V_GET32_INDEXED OLD_THRU_PARM,SEG_ADDR_PTR,START_ADDR"
728   DATA "          V_MODULO PLOT_WORD_CNT,XFER_SIZE,TEMP"   !ADD FRAC OF SCAN.
729   DATA "          V_ADD TEMP,START_ADDR,START_ADDR"
730   DATA "          V_ADD TEMP,START_ADDR,START_ADDR  !W -> B"
731   DATA "          V_MULT SCAN_SIZE,START_SCAN,SCAN_OFFSET"
732   DATA "          V_MULT XFER_SIZE,MOD_OFFSET,MOD_OFFSET"
733   DATA "          V_ADD MOD_OFFSET,MOD_OFFSET,MOD_OFFSET !W TO BYTES"
734   DATA "          V_ADD START_ADDR,SCAN_OFFSET,START_ADDR"
735   DATA "          V_ADD START_ADDR,MOD_OFFSET,START_ADDR"
736     !NOW READ ONE BLOCK FROM DISC
737   DATA "          F_READ_DISC TIME_BUFFER,BLOCK_OFFSET,PLOT_BLK_SIZE,0"
738   DATA ".                   PLOT_BLK_SIZE,DISC_HP_IB,DISC_UNIT,DISC_VOL"
739   DATA ".                   START_ADDR"
740   DATA "        C_BLT NEXTT,TRACE_NUM,MOD_COUNT     !UNTIL LAST TRACE"
741   DATA "      C_BLT NEXTS,SCAN_NUM,PLOT_NUM_SCANS !UNTIL LAST SCAN"
742     !
743     !NOW SEND BACK THE ENTIRE BLOCK.
744   DATA "SEND:"
745   DATA "      F_RELEASE_BUS HOST_HP_IB"
746   DATA "      F_WAIT_TO_SIG MINUS_ONE"
747   DATA "      C_END"
748   DATA "ERR1:            !COME HERE IF RAN OUT OF ROOM IN SEG TABLE."
749   DATA "      F_RELEASE_BUS HOST_HP_IB"
750   DATA "      F_WAIT_TO_SIG SEG_ERR"
751   DATA "      C_END"
752   DATA "EL_COMPLETO"
753     !
754 End_icode:    !
755   !
756 SUBEND
757   ! PAGE -> 
758   !***********************************************************************
759 Thru_init_hw:SUB Thru_init_hw
760   !
761   ! Used at power-up or configuration change to allocate RAM blocks
762   ! in the HP-IB module.
763   ! Block ID numbers are saved in COMMON to be passed to
764   ! the ICODE programs later.
765   !
766   COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
767   COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
768!
769! ALLOCATE ICODE BLOCKS
770!
771   Hw_cmd("ABRT")
772   DISP "Allocating blocks"
773   Hw_cmd("DISA")
774   Thru_def_blk(4096,2,Thru_icode_id)     !2
775   Thru_def_blk(1268,16,Thru_parm_id)     !4
776   Thru_def_blk(4096,2,Read_icode_id)     !6
777   Thru_def_blk(73728,2,Time_buffer)      !8
778   Thru_def_blk(1024,2,Work_blockid)      !10
779   Thru_def_blk(1268,16,Disc_parm_id)     !12
780   DISP 
781 SUBEND
782   !
783   ! PAGE -> 
784   !*********************************************************************
785 Thru_init_parm:SUB Thru_init_parm
786   !
787   ! Initializes the array that will be used as a parameter block for
788   ! the Through-put ICODE program.  Note that this block will also
789   ! be updated by the ICODE program and stored on disc by it after the
790   ! through-put is complete,
791   ! and should be read back into host to determine plot parameters.
792   ! Should be called whenever CNFG, MEAS, or INPT parameters are changed.
793   !
794   COM /Appl_thru_parms/ Thru_length,Num_loops,Fallout_mode,Trigger_mode,Xfer_mode,Disc_addr,Disc_unit,Disc_vol
795   COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
796   COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
797   COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
798   !
799   INTEGER Extra_loops,Modules(1:63),Addr_h(1:50),Addr_l(1:50)
800   INTEGER Disc_segments
801   REAL Addr(1:50),Loops(1:50),Start_addr,Xfer_size,Module_count
802   ALLOCATE Module_name$(1:63)[40]
803   !
804   ! FIRST GET THE PARMS SET UP BY Meas_ subprograms...
805   DISP "Initializing through-put parameter block"
806   !
807   Disc_addr=FNMeas_thru_parm("DISC ADDRESS")
808   Disc_unit=FNMeas_thru_parm("DISC UNIT")
809   Disc_vol=FNMeas_thru_parm("DISC VOLUME")
810   Xfer_mode=FNMeas_thru_parm("TRANSFER MODE")
811   Fallout_mode=FNMeas_thru_parm("FALLOUT")
812   Trigger_mode=FNMeas_thru_parm("TRIGGER")
813   Num_loops=FNMeas_thru_parm("NUMBER LOOPS")
814   Thru_length=FNMeas_thru_parm("THRUPUT LENGTH")
815   Xfer_size=FNMeas_thru_parm("TRANSFER SIZE")
816     !
817   Extra_loops=2    !TO ALLOW FOR INHERENT DELAY IN FIFO OVERFLOW ERR.
818     !
819     ! START ADDR OF ICODE PARAMETER BLOCK (AFTER SESSION AND SETUP INFO)
820     ! 288 SECTORS.
821   File_start_addr=FNMeas_thru_parm("START ADDR")+288.*256.
822  !
823  ! This is the start address of the actual Thru-put data. Must be on
824  ! a 256 byte boundary.
825   Start_addr=File_start_addr+256.*8.   ! ALLOW ROOM FOR ICODE PARM BLOCK.
826   !
827   Cnfg_labels("ALL INPUT",Module_name$(*),Num_inputs)
828   Scan_size=Xfer_size*2*Num_inputs
829   !
830   Thru_sector_tbl((Num_loops+2),Scan_size,Addr(*),Loops(*),Disc_segments)
831   !
832   FOR I=1 TO Disc_segments
833     Lib_32_to_16(Addr(I),Addr_h(I),Addr_l(I))
834   NEXT I
835   !
836   !
837   ! GET LIST OF ACTIVE INPUT MODULES.
838   !
839   FOR I=1 TO Num_inputs
840     Modules(I)=FNCnfg_get_modnum(Module_name$(I))
841   NEXT I
842   !
843   MAT Thruputacq_in= (0)          ! EVERYTHING DEFAULTS TO 0 UNLESS
844                                   ! EXPLICITLY DEFINED BELOW.
845   !
846   Thruputacq_in(0)=FNHw_host_addr   ! HOST HP_IB
847   Thruputacq_in(1)=Disc_addr      ! DISC HP_IB ADDRESS
848   Thruputacq_in(2)=Disc_unit      ! DISC UNIT NUMBER
849   Thruputacq_in(3)=Disc_vol       ! DISC VOLUME NUMBER
850   Lib_32_to_16(Num_loops,Thruputacq_in(4),Thruputacq_in(5))   !NUM LOOPS
851   Thruputacq_in(6)=Extra_loops    ! EXTRA LOOPS (FOR SAFETY)
852   Thruputacq_in(7)=Xfer_mode      ! SAMPLE MODE   0=BLOCK  1=CONTINOUS
853   ! SCAN SIZE IN BYTES:
854   Lib_32_to_16(2*Xfer_size*Num_inputs,Thruputacq_in(8),Thruputacq_in(9))
855   Thruputacq_in(10)=Fallout_mode   ! FALLOUT MODE
856   Thruputacq_in(11)=Trigger_mode  ! TRIGGER MODE
857   Thruputacq_in(12)=500           ! STATUS_BLOCK OFFSET
858   Thruputacq_in(13)=33            ! ADDRESS BLOCK OFFSET
859   Thruputacq_in(14)=434           ! MODULE LIST OFFSET
860   Thruputacq_in(15)=1012          ! PLOT PARAMETER LIST OFFSET
861   ! FILE START ADDRESS IN BYTES. MSW,LSW (PUT SESSION INFO HERE)
862   Lib_32_to_16(File_start_addr,Thruputacq_in(16),Thruputacq_in(17))
863  !
864  !  Thruputacq_in(18) to Thruputacq_in(32) RESERVED FOR FUTURE EXPANSION.
865     !
866     ! DISC INFO BLOCK FOR THRUPUT INSTRUCTION:
867   Thruputacq_in(33)=Disc_segments ! NUMBER OF DISC SEGMENTS
868   Ptr=33
869   FOR Seg_num=1 TO Disc_segments     !Thruputacq_in(34) thru (433) are seg table
870     Ptr=Ptr+1
871     Thruputacq_in(Ptr)=0          !NUMBER OF LOOPS IN THIS SEGMENT(HIGH)
872     Ptr=Ptr+1
873     Thruputacq_in(Ptr)=Loops(Seg_num)  !DITTO, LOW WORD.
874     Ptr=Ptr+1
875     Thruputacq_in(Ptr)=Addr_h(Seg_num) !ADDRESS OF THIS SEG. (HIGH WORD)
876     Ptr=Ptr+1
877     Thruputacq_in(Ptr)=Addr_l(Seg_num) !ADDRESS OF THIS SEG. (LOW WORD)
878   NEXT Seg_num
879 !
880  ! MODULE LIST INFO FOR THRUPUT INSTRUCTION:
881   Thruputacq_in(434)=Xfer_size       ! TRANSFER SIZE
882   Thruputacq_in(435)=0               ! UNUSED
883   Thruputacq_in(436)=Num_inputs
884   FOR I=1 TO Num_inputs             ! 437 TO 499 ARE INPUT MODULE ADDRESSES.
885     Thruputacq_in(436+I)=Modules(I)
886   NEXT I
887  !
888     ! DOWN LOAD THRUPUT PARAMETER BLOCK
889     !
890   DISP "Downloading through-put parameter block"
891     !
892   Hw_write_blk(Thru_parm_id,Thruputacq_in(*))
893     !
894   DISP ""
895 SUBEND
896   ! PAGE -> 
897   !***********************************************************************
898 Appl_main:SUB Appl_main(Init)
899     !
900     !  This is the main loop for the application.  It sets up for
901     !  the through-put, sets up the softkeys, and loops, processing
902     !  key presses, updating the through-put setup or starting the
903     !  through-put, as requested.  There are two sets of softkeys
904     !  associated with this subprogram.
905     !
906     !  On entry the THRUPUT softkeys
907     !  are set up.  These allow  changing the input and source module
908     !  setups, as well as the global measurement parameters.
909     !
910     !  The POST THRUPUT keys allow the user to plot data already on
911     !  the disc.
912     !
913     !    INPUTS:   Init:  1 forces Appl_init to be called (on power up or
914     !                     configuration change)
915     !
916   COM /Appl_data/ Data_array(*),Data_header(*)
917     ! Setup initial softkeys
918   GOSUB Appl_main_keys
919     !
920     ! First init everything, if S.P.A.M. didn't do it.
921   IF Init THEN CALL Appl_init
922     !
923     ! FLAGS FOR CONTROL:
924   Restart_meas=0        !SET WHEN WE WANT TO START A THRUPUT
925   Display_changed=1     !SET WHEN WE WANT TO UPDATE DISPLAY
926   Setup_changed=1       !SET WHEN WE WANT TO UPDATE THRUPUT PARMS.
927   Leave_me=0            !SET WHEN WE WISH TO EXIT APPLICATION.
928   Good_disc_data=0      !SET WHEN THERE IS GOOD DISC DATA ON THE T-PUT FILE
929   Mod_all_plots=1       !USED WITH NEXT/PREV RECORD KEYS IN POST THRUPUT.
930   Repaint=0             !USED WHEN CURRENT DATA IS OK, BUT UPDATE DISPLAY.
931   Thru_check_disc(Disc_present,Good_disc_data)
932   New_disc_data=Good_disc_data
933   REPEAT
934       !
935     IF Main_keys THEN     ! DO THE THROUGH-PUT KEYS (INPT,SRCE,MEAS SETUPS)
936       IF NOT Good_disc_data THEN 
937         IF Disc_present THEN 
938           DISP "Press START to begin through-put"
939         ELSE
940           DISP "Press MEASURE SETUP to select through-put file or HELP to create the file"
941         END IF
942       ELSE
943         DISP "Press START to begin through-put or POST THRUPUT to view disc data"
944       END IF
945       IF Disc_present THEN 
946         IF Restart_meas THEN 
947           ON KEY 7 LABEL FNUser_keylabel$("STOP") CALL User_key7isr
948         ELSE
949           ON KEY 7 LABEL FNUser_keylabel$("START") CALL User_key7isr
950         END IF
951       ELSE
952         ON KEY 7 LABEL "" GOSUB Appl_dummy
953       END IF
954       !
955       IF Disc_present THEN 
956         IF Setup_changed THEN 
957           Thru_init_parm
958           Setup_changed=0
959         END IF
960         IF Restart_meas THEN 
961           Appl_start(Good_disc_data)
962           ON KEY 7 LABEL "" GOSUB Appl_dummy    !erase "STOP" key
963           IF FNUser_check_key=7 THEN Swallow=FNUser_get_key
964           Restart_meas=0
965           Display_changed=1
966           New_disc_data=Good_disc_data
967           IF Good_disc_data THEN Keys_changed=1
968         END IF
969       ELSE
970         IF Restart_meas THEN 
971           User_error("CAN'T DO THROUGH-PUT WITHOUT A DISC.. CHECK HP-IB ADDRESS & FILENAME")
972           Restart_meas=0
973         END IF
974       END IF
975       !
976       REPEAT
977         Appl_do_main(Restart_meas,Setup_changed,Disc_present,Good_disc_data,New_disc_data,Keys_changed,Leave_me)
978       UNTIL NOT FNUser_key_press
979       !
980       IF Keys_changed THEN 
981         Keys_changed=0
982         First_time=1
983         DISP 
984         GOSUB Appl_other_keys
985       ELSE
986         GOSUB Appl_main_keys
987       END IF
988     !
989     !
990     ELSE    !OTHER KEYS (POST-THRUPUT)
991       IF New_disc_data OR First_time THEN   !WE JUST DID A THROUGH-PUT, LET'S GET IT.
992         DISP "Checking for good disc data"
993         Thru_check_disc(Disc_present,Good_disc_data)
994         Thru_post_init
995         Thru_init_pp
996         Display_changed=1
997         New_disc_data=0
998         First_time=0
999       END IF
1000      IF Display_changed AND Good_disc_data THEN   !WE NEED TO GET DATA FROM DISC.
1001        Thru_update_pp
1002        Appl_update
1003        Thru_read_disc(New_data)
1004        Display_changed=New_data
1005        Good_disc_data=New_data
1006        Skip_plot=NOT New_data
1007      END IF
1008      IF (Display_changed OR Repaint) AND Good_disc_data THEN 
1009        DISP "Plotting axis"
1010        Disp_plot_axis
1011        DISP "Plotting data"
1012        Disp_plot_data(Data_array(*),Data_header(*))
1013        DISP ""
1014        Display_changed=0
1015        Repaint=0
1016      END IF
1017      IF Skip_plot THEN Good_disc_data=1
1018      DISP "Waiting for softkey"
1019      REPEAT
1020        Appl_do_other(Mod_all_plots,Display_changed,Repaint,Keys_changed)
1021      UNTIL NOT FNUser_key_press
1022      IF Keys_changed THEN 
1023        Keys_changed=0
1024        GOSUB Appl_main_keys
1025      ELSE
1026        GOSUB Appl_other_keys
1027      END IF
1028    END IF
1029  UNTIL Leave_me
1030  SUBEXIT
1031  !
1032 Appl_dummy: !
1033  RETURN 
1034 !
1035 Appl_main_keys:!
1036  Main_keys=1
1037  ON KEY 0 LABEL "" GOSUB Appl_dummy
1038  ON KEY 1 LABEL FNUser_keylabel$("INPUT SETUP") CALL User_key1isr
1039  ON KEY 2 LABEL FNUser_keylabel$("SOURCE SETUP") CALL User_key2isr
1040  ON KEY 3 LABEL "" GOSUB Appl_dummy
1041  ON KEY 4 LABEL FNUser_keylabel$("MEASURE SETUP") CALL User_key4isr
1042  IF NOT Good_disc_data THEN 
1043    ON KEY 5 LABEL "" CALL User_key5isr
1044  ELSE
1045    ON KEY 5 LABEL FNUser_keylabel$("POST THRUPUT") CALL User_key5isr
1046  END IF
1047  ON KEY 6 LABEL FNUser_keylabel$("HELP") CALL User_key6isr
1048  ON KEY 8 LABEL FNUser_keylabel$("EXIT") CALL User_key8isr
1049  ON KEY 9 LABEL "" GOSUB Appl_dummy
1050  RETURN 
1051  !
1052 Appl_other_keys:!
1053  Main_keys=0
1054  ON KEY 0 LABEL "" GOSUB Appl_dummy
1055  ON KEY 1 LABEL FNUser_keylabel$("<PREV REC") CALL User_key1isr
1056  IF Mod_all_plots THEN 
1057    ON KEY 2 LABEL FNUser_keylabel$("ALL PLOTS") CALL User_key2isr
1058  ELSE
1059    ON KEY 2 LABEL FNUser_keylabel$("FIRST PLOT") CALL User_key2isr
1060  END IF
1061  ON KEY 3 LABEL FNUser_keylabel$("NEXT REC>") CALL User_key3isr
1062  ON KEY 4 LABEL FNUser_keylabel$("DISPLAY SETUP") CALL User_key4isr
1063  ON KEY 5 LABEL FNUser_keylabel$("THRUPUT") CALL User_key5isr
1064  ON KEY 6 LABEL FNUser_keylabel$("MARKER") CALL User_key6isr
1065  ON KEY 7 LABEL FNUser_keylabel$("PLOT BLKSIZE") CALL User_key7isr
1066  ON KEY 8 LABEL "" GOSUB Appl_dummy
1067  ON KEY 9 LABEL "" GOSUB Appl_dummy
1068  RETURN 
1069  !
1070 SUBEND
1071  !
1072  !
1073  ! PAGE -> 
1074  !***********************************************************************
1075 Appl_do_main:SUB Appl_do_main(Start,Setup_modified,Disc_present,Good_disc_data,New_disc_data,Keys_changed,Leave_me)
1076  !
1077  !  This subprogram is called when the THRUPUT softkeys are active.
1078  !
1079  !  OUTPUTS: Start:          1= Start a through-put.
1080  !           Setup_modified: Parameters affecting through-put have changed.
1081  !           Disc_present:   A disc is present at the selected address.
1082  !           Good_disc_data: The current file has good data.
1083  !           New_disc_data:  Set when throughput file changed.
1084  !           Keys_changed:   Switch to POST THRUPUT keys.
1085  !           Leave_me:       Exit the application.
1086  !
1087  COM /Appl_data/ Data_array(*),Data_header(*)
1088  Key_num=FNUser_get_key
1089    !
1090  SELECT Key_num
1091  CASE 1
1092    ON KEY Key_num LABEL FNUser_keylabel$("MAIN") CALL User_key1isr
1093    CALL Inpt_spread(Change_in_hw)
1094    OFF KEY Key_num
1095  CASE 2
1096    ON KEY Key_num LABEL FNUser_keylabel$("MAIN") CALL User_key2isr
1097    CALL Srce_spread(Change_in_hw)
1098    OFF KEY Key_num
1099  CASE 3
1100  CASE 4
1101    ON KEY Key_num LABEL FNUser_keylabel$("MAIN") CALL User_key4isr
1102    CALL Meas_spread(Change_in_hw)
1103    IF Change_in_hw THEN 
1104      Thru_check_disc(Disc_present,Good_disc_data)
1105      New_disc_data=Disc_present AND Good_disc_data
1106    END IF
1107    OFF KEY Key_num
1108  CASE 5
1109    Keys_changed=1
1110  CASE 6
1111    Appl_help
1112  CASE 7
1113    Start=1
1114  CASE 8
1115    Leave_me=1
1116  END SELECT
1117      !
1118  IF Change_in_hw THEN Setup_modified=1
1119      !
1120  IF FNUser_key_press THEN 
1121    IF FNUser_check_key=Key_num THEN Key_num=FNUser_get_key
1122  END IF
1123 SUBEND
1124  !
1125  ! PAGE -> 
1126  !***********************************************************************
1127 Appl_do_other:SUB Appl_do_other(Mod_all_plots,Disp_modified,Repaint,Keys_changed)
1128  !  This subprogram gets called when the 'POST THRUPUT' set of softkeys is
1129  !  active.
1130  !
1131  !  OUTPUTS:  Mod_all_plots: Defines function of PREV REC and NEXT REC keys
1132  !            Disp_modified: Parameters effecting plots may have changed.
1133  !            Repaint:       Re-draw display.
1134  !            Keys_changed:  Return to THRUPUT (Main) keys.
1135  !
1136  COM /Appl_data/ Data_array(*),Data_header(*)
1137  Key_num=FNUser_get_key
1138    !
1139    !
1140  SELECT Key_num
1141  CASE 1
1142    Post_prev_rec(Mod_all_plots,Disp_modified)
1143  CASE 2
1144    Mod_all_plots=(Mod_all_plots+1) MOD 2
1145  CASE 3
1146    Post_next_rec(Mod_all_plots,Disp_modified)
1147  CASE 4
1148    ON KEY Key_num LABEL FNUser_keylabel$("EXIT DISPLAY") CALL User_key4isr
1149    CALL Post_spread(Disp_modified)
1150    Repaint=1
1151    OFF KEY Key_num
1152  CASE 5
1153    Keys_changed=1
1154  CASE 6
1155    ON KEY Key_num LABEL FNUser_keylabel$("EXIT MARKER") CALL User_key6isr
1156    CALL Disp_do_mkr(Data_array(*),Data_header(*),0)
1157    OFF KEY Key_num
1158  CASE 7
1159    CALL Thru_new_bsize(Disp_modified)
1160  CASE 8
1161    BEEP 
1162  END SELECT
1163    !
1164  IF FNUser_key_press THEN 
1165    IF FNUser_check_key=Key_num THEN Key_num=FNUser_get_key
1166  END IF
1167 SUBEND
1168  !
1169  ! PAGE -> 
1170  !***********************************************************************
1171 Thru_do_thruput:SUB Thru_do_thruput(Good_disc_data)
1172  !
1173  !  Executes the through-put ICODE program, that has already been
1174  !  downloaded into the 35651 by Thru_init_icode.  We also assume that
1175  !  the parameter block has been downloaded by Thru_init_parms
1176  !
1177  !  Control of the HP-IB is passed to the ICODE program while it
1178  !  does the through-put.  If Cont --> Blk transfer mode is in effect,
1179  !  and the through-put does not complete in Continuous mode, control is
1180  !  passed again while the rest of the data is gathered in block mode.
1181  !
1182  !  Once the through-put is complete, ICODE again requests the bus to
1183  !  store the parameter block on disc.
1184  !
1185  !  This subprogram should be followed by Thru_send_setup, to store
1186  !  other setup information on the disc file.
1187  !
1188  !  OUTPUTS:  Good_disc_data:  Through-put successfully completed.
1189  !
1190  COM /Appl_thru_parms/ Thru_length,Num_loops,Fallout_mode,Trigger_mode,Xfer_mode,Disc_addr,Disc_unit,Disc_vol
1191  COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
1192  COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
1193  INTEGER Zip
1194    !
1195  DISP "Starting through-put program"
1196  !
1197  Hw_cmd("ABRT;CLR")
1198  Hw_cmd("PROG"&VAL$(Thru_icode_id))
1199  Good_disc_data=0
1200    ! RESET THE REV CODE, IN CASE THRUPUT BOMBS.
1201  Zip=0
1202  ASSIGN @File TO FNMeas_file_spec$;FORMAT OFF
1203  OUTPUT @File;Zip
1204  ASSIGN @File TO *
1205  !
1206  ! WAIT FOR 35651 TO REQUEST BUS
1207  !
1208  Hw_pass_cntrlr(10)
1209  IF FNHw_io_error THEN CALL User_stop("Error -- Unable to pass control to HP-IB module.")
1210  Sel_code=FNHw_cur_dev_sel DIV 100
1211  REPEAT       !MAKE SURE ITS BEEN PASSED.
1212    STATUS Sel_code,6;I
1213  UNTIL BIT(I,6)=0
1214  DISP "Doing through-put to disc"
1215    ! Hw_wait_cntrlr   commented out to avoid system hang when control
1216                       !is not passed back due to an Icode error.
1217  Thru_wait_cntr(1.E+6,Aborted)
1218  DISP ""
1219  Stat=VAL(FNHw_cmd_rsp$("STA?"))
1220  IF BIT(Stat,5) OR Aborted THEN       ! ERR or aborted
1221    GOSUB Thru_chk_errors
1222    IF NOT Aborted THEN GOSUB Thru_wait_end
1223    SUBEXIT
1224  END IF
1225  Signal_val=VAL(FNHw_cmd_rsp$("WSG?"))
1226  IF Signal_val=-1 THEN    !THRUPUT SUCCESSFUL
1227    Good_disc_data=1
1228    GOSUB Thru_wait_end
1229    GOSUB Thru_chk_errors
1230    SUBEXIT
1231  END IF
1232  IF Fallout_mode=0 AND Xfer_mode=1 THEN    !NO FALLOUT.
1233    User_error("THROUGH-PUT DID NOT FINISH; "&VAL$(Signal_val)&" VALID SCANS")
1234    IF Signal_val>0 THEN Good_disc_data=1
1235    GOSUB Thru_wait_end
1236    GOSUB Thru_chk_errors
1237    SUBEXIT
1238  END IF
1239   !ELSE  FINISH THROUGH PUT IN BLOCK MODE.
1240  DISP "Falling through to block mode"
1241  Hw_pass_cntrlr(10)
1242  IF FNHw_io_error THEN CALL User_stop("Error -- Unable to pass control to HP-IB module.")
1243 !
1244 ! MAKE SURE IT HAS PASSED BEFORE TRYING TO GET IT BACK.
1245  REPEAT
1246    STATUS 7,4;I
1247  UNTIL BIT(I,15)=0
1248 !
1249  DISP "Finishing through-put in block mode"
1250  Thru_wait_cntr(40,Aborted)
1251  IF NOT Aborted THEN 
1252    DISP "Through-put complete"
1253    Good_disc_data=1
1254    GOSUB Thru_wait_end
1255  END IF
1256  GOSUB Thru_chk_errors
1257  SUBEXIT
1258 Thru_wait_end:   !
1259  Hw_pass_cntrlr(10)
1260  IF FNHw_io_error THEN CALL User_stop("Error -- Unable to pass control to HP-IB module.")
1261  DISP "Saving setup info"
1262  REPEAT   !make sure control has passed.
1263    STATUS 7,4;I
1264  UNTIL BIT(I,15)=0
1265  Thru_wait_cntr(20,Aborted)
1266  DISP ""
1267  RETURN 
1268 Thru_chk_errors:   !
1269  Errors=FNDiag_chk_errors
1270  IF Errors THEN WAIT 4
1271  RETURN 
1272 SUBEND
1273  !
1274  !***********************************************************************
1275  ! PAGE -> 
1276 Thru_send_setup:SUB Thru_send_setup
1277  !
1278  !  Builds the session info block and the setup info block, and stores
1279  !  them at the start of the through-put file on disc.
1280  !
1281  ! The session block has the global parameters.  It occupies the
1282  ! first 256 bytes of the BDAT file.
1283  !Session block format:
1284  ! Rev_code      16 bit integer     0 if no valid data in file.
1285  ! Zoom_mode     16 bit boolean     0 if baseband, 1 if zoom on.
1286  ! Center_freq   64 bit float       Center freq of input modules.
1287  ! Span Freq     64 bit float       Span in Hz.
1288  ! Trigger dly   64 bit float       delay in samples.
1289  ! not used      64 bit float
1290  ! Timedate      64 bit float       val of TIMEDATE when stored
1291  !
1292  ! The setup info block has a set of information about each INPUT
1293  ! module involved in the through-put.
1294  !
1295  ! Setup block format on disc:
1296  !  For each input module:
1297  !    NAME          TYPE          OFFSET          NUM BYTES.
1298  !  Module addr.  Integer            0                 2
1299  !  Model num.    string             1                12
1300  !  serial num.   string             7                16
1301  !  channel name  string            14                44 (max)
1302  !   unused       string           varies             28 (max)
1303  !  module setup  string           varies            184
1304  !  cal data      unknown          varies            880
1305  !
1306  !                                  SUB-TOTAL       1166 BYTES
1307  !                            MAX OF 63 MODULES:   73458 BYTES
1308  !                     ROUNDED TO MULTIPLE OF 256 BYTES : 73472 BYTES
1309  !                                                       (287 sectors)
1310  !
1311 Start_com: !
1312  !
1313  COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
1314  COM /Appl_thru_parms/ Thru_length,Num_loops,Fallout_mode,Trigger_mode,Xfer_mode,Disc_addr,Disc_unit,Disc_vol
1315  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1316  COM /Thru_setup_parm/ Model_num$(*),Ser_num$(*),Module_label$(*),Not_used$(*),Setup$(*),INTEGER Mod_addr(*)
1317  INTEGER Rev_code,Zoom_mode,Minus_99
1318  INTEGER Sess_temp(0:127) BUFFER    !FOR SESSION INFO (1 DISC SECTOR)
1319  REAL Cfreq,Span,Tdly,Zip
1320  ALLOCATE Big_string$[210]
1321  ALLOCATE INTEGER Dummy_cal(1:440)
1322  MAT Dummy_cal= (0)
1323  !
1324  ! PUT SESSION INFO INTO A 256 BYTE BUFFER, THEN SEND THE WHOLE ARRAY.
1325  ASSIGN @Buff TO BUFFER Sess_temp(*);FORMAT OFF
1326  ASSIGN @File TO FNMeas_file_spec$;FORMAT OFF
1327  DISP "Writing session setup data to disc"
1328    !
1329    ! INITIALIZES THE SESSION INFO
1330  Rev_code=1
1331  Minus_99=-99   !END OF SETUP MARKER.
1332  Zip=0    !USE FOR DUMMY VISTA THROUGH-PUT PARMS.
1333  Zoom_mode=FNMeas_thru_parm("ZOOM MODE")
1334  Cfreq=FNMeas_thru_parm("CENTER FREQ")
1335  Span=FNMeas_thru_parm("SPAN")
1336  Tdly=FNMeas_thru_parm("TRIG DELAY")
1337  OUTPUT @Buff;Rev_code,Zoom_mode,Cfreq,Span,Tdly,Zip,TIMEDATE
1338  OUTPUT @File;Sess_temp(*)
1339  !
1340  ! NOW SEND THE SETUP INFO.
1341  DISP "Writing hardware setup data to disc"
1342  Cnfg_labels("ALL INPUT",Module_label$(*),Num_mods)   !GET ACTIVE INPUTS.
1343  Cnfg_cmd("ALL INPUT","ID?;SET?;SER?")
1344  FOR Mod_num=1 TO Num_mods
1345    Mod_addr(Mod_num)=FNCnfg_get_modnum(Module_label$(Mod_num))
1346    Big_string$=FNCnfg_rsp$(Module_label$(Mod_num))
1347  !
1348  !GET EVERYTHING IN ONE STRING; STRIP OUT COMMAS AND '#I000180'
1349    ENTER Big_string$ USING "8A,9X,180A,X,K";Model_num$(Mod_num),Setup$(Mod_num),Ser_num$(Mod_num)
1350    Ser_num$(Mod_num)=FNUser_fill$(Ser_num$(Mod_num),12)   !pad ser # to 12 char
1351  !
1352  !PUT IT ON DISC FILE, INTERNAL FORMAT (FORMAT OFF)
1353    OUTPUT @File;Mod_addr(Mod_num),Model_num$(Mod_num),Ser_num$(Mod_num),Module_label$(Mod_num),RPT$(" ",24),Setup$(Mod_num)
1354  !
1355  ! FOR UPWARD COMPATIBILITY:
1356    OUTPUT @File;Dummy_cal(*)
1357  NEXT Mod_num
1358  IF Num_mods<63 THEN OUTPUT @File;Minus_99,Model_num$(1),Ser_num$(1),Module_label$(1),RPT$(" ",24),Setup$(1)
1359  CONTROL @File,7;297,1    !set eof to end of the icode parms.
1360  DISP 
1361 SUBEND
1362  ! PAGE -> 
1363  !***********************************************************************
1364 Appl_powerup:SUB Appl_powerup
1365  !
1366  ! Called at power up (surprise!) to initialize the Input and Source
1367  ! modules, and their spread sheets.
1368  !
1369  DIM Setup$(1:8)[20]
1370  REDIM Setup$(1:6)
1371  Setup$(1)="INPUT MODE"
1372  Setup$(2)="COUPLING"
1373  Setup$(3)="GROUNDING"
1374  Setup$(4)="RANGE"
1375  Setup$(5)="TRIG LEVEL"
1376  Setup$(6)="TRIG SLOPE"
1377  Inpt_init(Setup$(*))
1378  REDIM Setup$(1:8)
1379  Setup$(1)="MODE"
1380  Setup$(2)="OFFSET"
1381  Setup$(3)="AMPLITUDE"
1382  Setup$(4)="SINE FREQ"
1383  Setup$(5)="SPAN"
1384  Setup$(6)="CENTER FREQ"
1385  Setup$(7)="TRIG"
1386  Setup$(8)="BURST %"
1387  Srce_init(Setup$(*))
1388    !
1389    !
1390 SUBEND
1391  !
1392  ! Page > 
1393  !
1394  !***********************************************************************
1395 Thru_check_disc:SUB Thru_check_disc(Disc_present,Good_disc_data)
1396  !
1397  ! Gets parameter blocks from the disc, and checks for a valid
1398  ! Rev code in the session parms.
1399  !
1400  ! OUTPUTS:  Disc_present: disc exists with a BDAT file as specified
1401  !                         by MEAS spread sheet.
1402  !           Good_disc_data:  Through-put data valid (rev code=1)
1403  !
1404  COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
1405  COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
1406  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1407  INTEGER Qstat,Set_unit,Set_vol,Set_length
1408  ALLOCATE File_spec$[23]
1409  File_spec$=FNMeas_file_spec$
1410  IF File_spec$="" THEN 
1411    Disc_present=0
1412    Good_disc_data=0
1413  ELSE
1414    Disc_present=1
1415 Get_parm: !
1416    Thru_get_parm(File_spec$,Good_disc_data)
1417  END IF
1418    !
1419 SUBEND
1420  ! PAGE -> 
1421  !***********************************************************************
1422 Thru_get_parm:SUB Thru_get_parm(File_spec$,Good_disc_data)
1423  !
1424  ! Pulls the session, setup and thruput parameters in from the
1425  ! through-put file on disc then puts em into COM blocks.
1426  ! The through-put disc info (HP-IB addr, unit, volume and host addr)
1427  ! is corrected to correspond to the current reality.
1428  !
1429  ! INPUTS:  File_spec$:  String containing file specification for
1430  !                       the through-put file.
1431  !
1432  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1433  COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
1434  COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
1435  COM /Thru_setup_parm/ Model_num$(*),Ser_num$(*),Module_label$(*),Not_used$(*),Setup$(*),INTEGER Mod_addr(*)
1436  ALLOCATE INTEGER Dummy_cal(1:440)    !CAL DATA NOT USED
1437    !
1438  Good_disc_data=0
1439    !
1440  ON ERROR GOTO Disc_error
1441  ASSIGN @Thru_file TO File_spec$
1442  ON END @Thru_file GOTO Empty_file
1443  ENTER @Thru_file;Session_info(*)
1444  IF Session_info(0)=0 THEN GOTO No_valid_data
1445  IF Session_info(0)<>1 THEN GOTO Bad_sess_info
1446  !
1447  !GET SETUP INFO
1448  Done=0
1449  I=0
1450  ON ERROR GOTO End_setup_info
1451  REPEAT
1452    I=I+1
1453    ENTER @Thru_file;Mod_addr(I),Model_num$(I),Ser_num$(I),Module_label$(I),Not_used$(I),Setup$(I),Dummy_cal(*)
1454    IF I=63 OR Mod_addr(I)=-99 THEN Done=1
1455  UNTIL Done=1
1456 !
1457 !GET ICODE PARAMETERS (MINUS POST-PROCESSING PARMS)
1458 Get_icode_parm:  !
1459  ON ERROR GOTO File_too_small
1460  CONTROL @Thru_file,5;289,1    !SET POINTER TO START OF ICODE PARM INFO
1461  Old_size=SIZE(Disc_parm,1)-1
1462  REDIM Disc_parm(0:Old_size-256)   !CAN'T READ POST PROC PARMS.
1463  ON ERROR GOTO No_disc_parm
1464  ENTER @Thru_file;Disc_parm(*)
1465  OFF ERROR 
1466  REDIM Disc_parm(0:Old_size)
1467  Good_disc_data=1
1468 !
1469 ! NOW FIX UP THE ADDRESS INFO; HP-IB ADDRESSES MAY HAVE CHANGED, ETC.
1470  Disc_parm(0)=FNHw_host_addr
1471  Disc_parm(1)=FNMeas_thru_parm("DISC ADDRESS")
1472  Disc_parm(2)=FNMeas_thru_parm("DISC UNIT")
1473  Disc_parm(3)=FNMeas_thru_parm("DISC VOLUME")
1474  SUBEXIT
1475 !
1476 Disc_error:!
1477  User_error("THROUGH-PUT FILE NOT FOUND: "&File_spec$)
1478  SUBEXIT
1479 No_valid_data:  !
1480  User_error("DATA NOT VALID IN FILE: "&File_spec$)
1481  OFF ERROR 
1482  SUBEXIT
1483 Bad_sess_info:  !
1484  User_error("WRONG REV CODE FROM SESSION SETUP.  FILE: "&File_spec$)
1485  OFF ERROR 
1486  SUBEXIT
1487 End_setup_info:  !
1488  IF I=0 THEN 
1489    User_error("ERROR WHILE READING SETUP DATA FROM: "&File_spec$)
1490    SUBEXIT
1491  ELSE
1492    Done=1
1493    GOTO Get_icode_parm
1494  END IF
1495 File_too_small:  !
1496  User_error("FILE TOO SMALL FOR THROUGH-PUTS: "&File_spec$)
1497  SUBEXIT
1498 No_disc_parm:  !
1499  User_error("ERROR WHILE READING ICODE PARMS FROM "&File_spec$)
1500  REDIM Disc_parm(0:Old_size)
1501  SUBEXIT
1502 Empty_file: !
1503  SUBEXIT
1504 SUBEND
1505  ! PAGE -> 
1506  !***********************************************************************
1507 Thru_init_pp:SUB Thru_init_pp
1508  !
1509  ! Initializes the plot parameters to default vals after having loaded the
1510  ! Throughput parameters from disc.
1511  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1512  Ptr=Disc_parm(12)   !POINTS TO ACTUAL SCANS.
1513  Lib_16_to_32(Disc_parm(Ptr),Disc_parm(Ptr+1),Num_scans)   !NUM_THRU_SCANS
1514  Num_scans=MIN(1,Num_scans)    !START OUT WITH 2 SCANS, IF WE HAVE 'EM.
1515  Lib_32_to_16(Num_scans,Disc_parm(Disc_parm(15)),Disc_parm(Disc_parm(15)+1))
1516  Disc_parm(Disc_parm(15)+2)=Disc_parm(Disc_parm(14))   !SCAN_SIZE=XFER_SIZE
1517  Num_plots=FNDisp_num_plots
1518  Disc_parm(Disc_parm(15)+3)=Num_plots
1519  FOR N=1 TO Num_plots
1520    Ptr=Disc_parm(15)+4*N
1521    Lib_32_to_16(1.0,Disc_parm(Ptr),Disc_parm(Ptr+1))   !START AT 1ST BLK.
1522    Disc_parm(Ptr+2)=1    !START AT FIRST POINT.
1523      ! FIND SEQUENCE OF MODULE IN SCAN.
1524    Disc_parm(Ptr+3)=FNPost_inpt_num(N)
1525      !
1526  NEXT N
1527 SUBEND
1528  ! PAGE -> 
1529  !***********************************************************************
1530 Thru_read_disc:SUB Thru_read_disc(Good_disc_data)
1531  !
1532  !Downloads the Disc_parm common block, with the updated plot parameters,
1533  !runs the read_disc icode program, and uploads the data into
1534  !the plot data buffer.
1535  !
1536  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1537  COM /Thru_blocks/ Thru_parm_id,Work_blockid,Time_buffer,Disc_parm_id
1538  COM /Thru_icode_blk/ Thru_icode_id,Read_icode_id
1539  COM /Appl_data/ Data_buffer(*),Data_header(*)
1540  !
1541  DISP "Reading disc"
1542  Parm_ptr=Disc_parm(15)
1543  Num_plots=Disc_parm(Parm_ptr+3)
1544  Plot_block_size=Disc_parm(Parm_ptr+2)
1545  Lib_16_to_32(Disc_parm(Parm_ptr),Disc_parm(Parm_ptr+1),Num_scans)
1546  Plot_length=Num_scans*Plot_block_size
1547  ! Plot_length=Plot_block_size
1548  REDIM Data_buffer(1:Num_plots,0:Plot_length-1)
1549  Hw_write_blk(Disc_parm_id,Disc_parm(*))
1550  WAIT .2
1551  Hw_cmd("PROG"&VAL$(Read_icode_id))
1552  Hw_pass_cntrlr
1553  Good_disc_data=1
1554  WAIT .2
1555    !  Hw_wait_cntrlr(120)    this line replaced to aviod hung system when
1556    !  HP-IB module gets error 405 and aborts the Icode before passing
1557    !  control back.
1558  CALL Thru_wait_cntr(10,Aborted)
1559  IF Aborted THEN 
1560    Good_disc_data=0
1561    Errors=FNDiag_chk_errors
1562    IF Errors THEN WAIT 4
1563    SUBEXIT
1564  END IF
1565  Sig_val$=FNHw_cmd_rsp$("WSG?")
1566  DISP ""
1567  SELECT Sig_val$
1568  CASE "-1"
1569    ALLOCATE INTEGER Temp(1:Num_plots,0:Plot_length-1)
1570    Hw_read_blk(Time_buffer,Temp(*))
1571    MAT Data_buffer= Temp
1572    SUBEXIT
1573  CASE "-2"
1574    User_error("TRIED TO READ PAST END OF SECTOR TABLE")
1575    Good_disc_data=0
1576    SUBEXIT
1577  END SELECT
1578 SUBEND
1579  ! PAGE -> 
1580  !***********************************************************************
1581 Thru_def_blk:SUB Thru_def_blk(Block_size,Hdr_size,Id,OPTIONAL Label$)
1582  !
1583  !This subprogram allocates a block in the 68000 space.
1584  !The block id is returned in Id.  The header block is initialized to 0
1585  !Label$ is reserved for future expansion
1586  !No error checking is performed to see if this space is available
1587  IF Hdr_size>0 THEN 
1588    Id=VAL(FNHw_cmd_rsp$("NEW "&VAL$(Block_size)&", "&VAL$(Hdr_size)&";NEW?"))
1589    ALLOCATE INTEGER Zero_blk(0:MAX(1,Hdr_size-1))
1590    Hw_write_blk(Id+1,Zero_blk(*))
1591  ELSE
1592    Id=VAL(FNHw_cmd_rsp$("NEW "&VAL$(Block_size)&";NEW?"))
1593  END IF
1594 SUBEND
1595  ! PAGE -> 
1596 !-------------------------------------------------------------------------
1597 Thru_def_spblk:SUB Thru_def_spblk(Block_size,Hdr_size,Id,OPTIONAL Label$)
1598  !
1599  !This subprogram allocates a block in the TMS320 space.
1600  !The block id is returned in Id.  The header block is initialized to 0
1601  !Label$ is reserved for future expansion
1602  !No error checking is performed to see if this space is available
1603  IF Hdr_size>0 THEN 
1604    Id=VAL(FNHw_cmd_rsp$("SNEW "&VAL$(Block_size)&", "&VAL$(Hdr_size)&";NEW?"))
1605    ALLOCATE INTEGER Zero_blk(0:MAX(1,Hdr_size-1))
1606    Hw_write_blk(Id+1,Zero_blk(*))
1607  ELSE
1608    Id=VAL(FNHw_cmd_rsp$("SNEW "&VAL$(Block_size)&";NEW?"))
1609  END IF
1610 SUBEND
1611  ! PAGE -> 
1612  !-----------------------------------------------------------------------
1613 Thru_disc_parm:DEF FNThru_disc_parm(Parm_name$,OPTIONAL Index_num)
1614  !
1615  ! Returns value of Disc_parm entry corresponding to Parm_name$
1616  ! Index_num may be used to select the parm from a particular module.
1617  ! It refers to the position of the module in the through-put scan
1618  ! sequence.  That is Index_num=1 is the 1st active input module, etc.
1619  !
1620  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1621  SELECT Parm_name$
1622  CASE "SCANS"    !NUM BLOCKS TO PLOT
1623    Lib_16_to_32(Disc_parm(Disc_parm(15)),Disc_parm(Disc_parm(15)+1),Parm_val)
1624    RETURN Parm_val
1625  CASE "BLOCKSIZE","BLOCK SIZE"    !PLOT BLOCK SIZE
1626    RETURN Disc_parm(Disc_parm(15)+2)
1627  CASE "NUM PLOTS","PLOT MOD COUNT"
1628    RETURN Disc_parm(Disc_parm(15)+3)
1629  CASE "START SCAN"
1630    Ptr=Disc_parm(15)+4*Index_num
1631    Lib_16_to_32(Disc_parm(Ptr),Disc_parm(Ptr+1),Parm_val)
1632    RETURN Parm_val
1633  CASE "START POINT"
1634    RETURN Disc_parm(Disc_parm(15)+4*Index_num+2)
1635  CASE "MOD OFFSET","MODULE OFFSET"
1636    RETURN Disc_parm(Disc_parm(15)+4*Index_num+3)
1637  CASE "XFER SIZE","TRANSFER SIZE"
1638    RETURN Disc_parm(Disc_parm(14))
1639  CASE "NUM MODULES","TOTAL MODULES","MODULE COUNT"
1640    RETURN Disc_parm(Disc_parm(14)+2)
1641  CASE "MODULE ADDR","MODULE ADDRESS"
1642    RETURN Disc_parm(Disc_parm(14)+2+Index_num)
1643  CASE "OVERLOAD"
1644    Ptr=Disc_parm(12)+Index_num*8
1645    Lib_16_to_32(Disc_parm(Ptr),Disc_parm(Ptr+1),Parm_val)
1646    RETURN Parm_val
1647  CASE "ACTUAL SCANS"
1648    Lib_16_to_32(Disc_parm(Disc_parm(12)),Disc_parm(Disc_parm(12)+1),Parm_val)
1649    RETURN Parm_val
1650  CASE "HP-IB"
1651    RETURN Disc_parm(0)
1652  CASE "DISC_HP-IB"
1653    RETURN Disc_parm(1)
1654  CASE ELSE
1655    User_stop("UNDEFINED PARAMETER FOR FNThru_disc_parm: "&Parm_name$)
1656    RETURN -1
1657  END SELECT
1658 FNEND
1659  ! PAGE -> 
1660  !-----------------------------------------------------------------------
1661 Thru_sess_parm:DEF FNThru_sess_parm(Parm_name$)
1662  ! Returns value of session_info entry corresponding to Parm_name$
1663  !
1664  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1665  !
1666  ! RETURNS PARAMETERS FROM SESSION_INFO BLOCK.
1667  INTEGER Temp(0:127) BUFFER
1668  ASSIGN @Buff TO BUFFER Temp(*);FORMAT OFF
1669  INTEGER Rev_code,Zoom,Pound_i
1670  REAL Center_freq,Span,Trig_delay
1671  OUTPUT @Buff;Rev_code,Zoom,Center_freq,Span,Trig_delay,Dummy,Stop_time
1672  MAT Temp= Session_info
1673  ENTER @Buff;Rev_code,Zoom,Center_freq,Span,Trig_delay,Dummy,Stop_time
1674  ASSIGN @Buff TO *
1675  SELECT Parm_name$
1676  CASE "SPAN"
1677    RETURN Span
1678  CASE "CENTER FREQ"
1679    RETURN "CENTER_FREQ"
1680  CASE "ZOOM"
1681    RETURN Zoom
1682  CASE "TRIG DELAY"
1683    RETURN Trig_delay
1684  CASE "REV CODE"
1685    RETURN Rev_code
1686  CASE "STOP TIME"
1687    RETURN Stop_time
1688  CASE ELSE
1689    User_stop("ILLEGAL PARAMETER FOR FNThru_sess_parm: "&Parm_name$)
1690    RETURN -1
1691  END SELECT
1692 FNEND
1693  ! PAGE -> 
1694  !-----------------------------------------------------------------------
1695 Thru_setup_parm:DEF FNThru_setup_parm$(Parm_name$,Module_num)
1696  ! Returns value of setup parm entry corresponding to Parm_name$
1697  ! Index_num may be used to select the parm from a particular input module.
1698  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1699  COM /Thru_setup_parm/ Model_num$(*),Ser_num$(*),Module_label$(*),Not_used$(*),Setup$(*),INTEGER Mod_addr(*)
1700 !
1701  SELECT Parm_name$
1702  CASE "RANGE","INPUT RANGE"
1703    RETURN Setup$(Module_num)[131,133]    !FOR INPUT MODS, THE "RNG" PARM.
1704  CASE ELSE
1705    User_stop(Parm_name$&" NOT IMPLEMENTED OR INCORRECT PARM FOR FNThru_setup_parm")
1706    RETURN -1
1707  END SELECT
1708 FNEND
1709  ! PAGE -> 
1710  !-----------------------------------------------------------------------
1711 Thru_update_pp:SUB Thru_update_pp
1712  !Called before reading disc to update plot parms from other spreadsheets.
1713  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1714    !
1715  Pp_ptr=Disc_parm(15)
1716  Num_plots=FNDisp_num_plots
1717  Disc_parm(Pp_ptr+3)=Num_plots
1718    !Scale = mSEC TO PLOT SCANS CONVERSION.
1719  Scale=FNThru_sess_parm("SPAN")*2.56E-3
1720  IF FNThru_sess_parm("ZOOM")=1 THEN Scale=Scale*2.   !interleaved time recsr
1721  Xfer_size=FNThru_disc_parm("XFER SIZE")
1722  FOR I=1 TO Num_plots
1723    Plot_num=FNPost_inpt_num(I)
1724    Ptr=Pp_ptr+4*I
1725    Start_n=FNPost_start_x(I)*Scale    !STARTING SAMPLE FOR PLOT.
1726    Start_scan=(Start_n DIV Xfer_size)+1   !START SCAN.
1727    Lib_32_to_16(Start_scan,Disc_parm(Ptr),Disc_parm(Ptr+1))
1728    Disc_parm(Ptr+2)=(Start_n MOD Xfer_size)+1    !START POINT IN SCAN.
1729    Disc_parm(Ptr+3)=Plot_num    !SEQUENCE IN SCAN.
1730  ! PRINT "PLOT:";I;"MOD:";Plot_num;"START_SCAN:";Start_scan;"START_N";Disc_parm(Ptr+2)
1731  NEXT I
1732 SUBEND
1733  ! PAGE -> 
1734  !-----------------------------------------------------------------------
1735 Thru_post_init:SUB Thru_post_init
1736 !
1737 ! Initializes the POST THRUPUT spreadsheet based on data read from
1738 ! the throughput disc.  Should be called after any throughput is
1739 ! done, and after reading the throughput parameters back with
1740 ! Thru_check_disc.
1741 !
1742  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1743  COM /Appl_buf_info/ Disp_choices$(*),Disp_types$(*),Num_inputs
1744  COM /Thru_setup_parm/ Model_num$(*),Ser_num$(*),Module_label$(*),Not_used$(*),Setup$(*),INTEGER Mod_addr(*)
1745    !
1746    ! Get the available module names from the disc parameters.
1747  Num_labels=FNThru_disc_parm("NUM MODULES")
1748  FOR I=1 TO Num_labels
1749    Disp_choices$(I)=Module_label$(I)
1750  NEXT I
1751    !
1752    ! 1 type  of plot for now
1753  Num_types=1
1754  Disp_types$(1)="Time"
1755    ! Setup Post module with titles
1756  Post_spread_set(Disp_choices$(*),Num_labels,Disp_types$(*),Num_types)
1757  Post_update_com
1758    !
1759 SUBEND
1760  ! PAGE -> 
1761  !-----------------------------------------------------------------------
1762 Thru_new_bsize:SUB Thru_new_bsize(Disp_modified)
1763    !
1764    ! Prompts the user for a new post processing blocksize
1765    ! and updates start_x box of DISPLAY SETUP spreadsheet appropriately.
1766  COM /Thru_disc_parms/ INTEGER Thruputacq_in(*),Session_info(*),Disc_parm(*)
1767    !
1768 Prompt:  !
1769  OUTPUT 2 USING "#,K";Disc_parm(Disc_parm(15)+2),CHR$(255),CHR$(72)
1770  ! INPUT "Enter block size for plots (2 blocks plotted)",New_bsize
1771  INPUT "Enter block size for plots",New_bsize
1772  IF New_bsize=Disc_parm(Disc_parm(15)+2) THEN 
1773    Disp_modified=0
1774    SUBEXIT
1775  END IF
1776  IF New_bsize<2 OR New_bsize>8192 THEN 
1777    User_error(VAL$(New_bsize)&" IS A BAD BLOCK SIZE (2<BSIZE<8192)")
1778    GOTO Prompt
1779  END IF
1780  Bsize=INT(2^(INT(LOG(New_bsize)/LOG(2)+.9999)))
1781  IF Bsize<>New_bsize THEN CALL User_error(VAL$(New_bsize)&" ROUNDED UP TO "&VAL$(Bsize))
1782  Disc_parm(Disc_parm(15)+2)=Bsize
1783  Num_plots=FNDisp_num_plots
1784  FOR P=1 TO Num_plots
1785    Post_new_startx(P,FNPost_start_x(P))
1786  NEXT P
1787  Disp_modified=1
1788 SUBEND
1789  ! PAGE -> 
1790  !-----------------------------------------------------------------------
1791 Thru_sector_tbl:SUB Thru_sector_tbl(Tot_loops,Scan_size,Address(*),Loops(*),INTEGER Num_segs)
1792  !
1793  ! Generates a table of addresses of good disc segments on the current
1794  ! through-put file for use by the throughput ICODE instruction.
1795  ! These addresses are returned in the array Address(*).  Loops(*) contains
1796  ! the number of through-put loops or scans in each segment.
1797  ! Enough addresses are generated to satisfy a through-put of Tot_loops
1798  ! scans.
1799  !
1800  ! INPUTS: Tot_loops:  Total number of loops or scans to do in
1801  !                     through-put.
1802  !         Scan_size:  Size of each scan in bytes.
1803  !
1804  ! OUTPUTS: Address(*):Start address of each segment to use.
1805  !          Loops(*):  Number of scans in each segment.
1806  !
1807  ALLOCATE Addr_low(1:100),Addr_hi(1:100),Bad_segs(1:100)
1808    !
1809  Cs80_describe(Num_heads,Num_sectors,Bytes_per_block)
1810    !
1811  IF Num_sectors<>0 THEN 
1812    Track_size=Num_sectors*Bytes_per_block
1813  ELSE
1814       ! default if unable to execute a CS80 DESCRIBE command
1815    Track_size=16384.0    ! 64 256 BYTE SEGMENTS PER SECTOR.
1816  END IF
1817    ! returns a list of bad segment addresses
1818  IF Num_heads<>0 AND Num_sectors<>0 THEN 
1819    Thru_bad_tracks(Num_heads,Num_sectors,Bad_segs(*),Num_bad)
1820  ELSE
1821       ! unable to determine bad segments if Num_heads and Num_sectors
1822       ! unknown
1823    Num_bad=0
1824  END IF
1825    !
1826  File_start=FNMeas_thru_parm("START ADDR")
1827  File_end=File_start+FNMeas_thru_parm("NUMBER RECORDS")*256.
1828  Thru_data_start=File_start+296.*256.
1829  Addr_low(1)=Thru_data_start   !START WITH ONE BIG SEGMENT FOR ENTIRE FILE.
1830  Addr_hi(1)=File_end
1831  N=1
1832  IF Num_bad>=1 THEN 
1833    FOR Bad_num=1 TO Num_bad
1834      IF Bad_segs(Bad_num)+Track_size>Addr_low(N) AND Bad_segs(Bad_num)<Addr_hi(N) THEN !BAD SEG COVERS OUR FILE.
1835        IF Bad_segs(Bad_num)<=Addr_low(N) THEN !IT OVERLAPS AT BOTTOM.
1836          Addr_low(N)=Bad_segs(Bad_num)+Track_size
1837        ELSE
1838          IF Bad_segs(Bad_num)+Track_size<Addr_hi(N) THEN !SPLIT INTO 2.
1839            Addr_low(N+1)=Bad_segs(Bad_num)+Track_size
1840            Addr_hi(N+1)=Addr_hi(N)
1841            Addr_hi(N)=Bad_segs(Bad_num)
1842            N=N+1
1843          ELSE !SHORTEN THE TOP SEGMENT.
1844            Addr_hi(N)=Bad_segs(Bad_num)
1845          END IF
1846        END IF
1847      END IF
1848    NEXT Bad_num
1849  END IF
1850  Tot_segs=N   !TOTAL NUMBER OF SEGMENTS IN FILE.
1851    !
1852    !NOW BUILD THE ACTUAL TABLE FOR THE THROUGH-PUT INSTRUCTION.
1853  Loops_to_do=Tot_loops
1854  I=0    !SEGMENT TABLE COUNTER
1855  Num_segs=0    !ADDRESS(*) AND Loops(*) COUNTER
1856  REPEAT
1857    I=I+1
1858    Seg_size=Addr_hi(I)-Addr_low(I)
1859    Num_loops=Seg_size DIV Scan_size
1860    IF Num_loops>0 THEN 
1861      Num_segs=Num_segs+1
1862      Address(Num_segs)=Addr_low(I)
1863      IF Num_loops>Loops_to_do THEN Num_loops=Loops_to_do
1864      Loops(Num_segs)=Num_loops
1865      Loops_to_do=Loops_to_do-Num_loops
1866    END IF
1867  UNTIL Loops_to_do=0 OR I=Tot_segs
1868  IF Num_segs=0 THEN 
1869     Num_segs=1
1870     Address(1)=Thru_data_start
1871     Loops(1)=Tot_loops
1872  END IF
1873    !
1874 SUBEND
1875  ! PAGE -> 
1876  !-----------------------------------------------------------------------
1877 Thru_bad_tracks:SUB Thru_bad_tracks(Num_heads,Num_sectors,Bad_addr(*),Num_bad)
1878  !
1879  ! This subprogram retrieves the spared sector list from the disc.
1881  ! This requires interrogating the disc with the CS-80 command
1882  !'EXECUTE UTILITY' with a micro-opcode of 196 (base 10) and a parameter
1883  ! of 1.  This will return the spare track table for the entire disc,
1884  ! in a 3-vector address format.  This subprogram must parse that table
1885  ! into a single vector (byte address) format, in ascending order
1886  ! of address.
1887  !
1888  ! OUTPUTS: Bad_addr(*): List of the addresses of the bad sectors,
1889  !                       in ascending order of address.  It
1890  !                       should be DIMmed to (1:100), although the
1891  !                       maximum number of bad sectors varies with
1892  !                       the particular model of disc drive.
1893  !          Num_bad:     The total number of bad sectors on the disc.
1894  !
1895  DIM Disc$[500]
1896   !
1897  Hpib=FNHw_cur_dev_sel DIV 100
1898  Disc_addr=FNMeas_thru_parm("DISC ADDRESS")
1899  Disc_unit=FNMeas_thru_parm("DISC UNIT")
1900  Disc_vol=FNMeas_thru_parm("DISC VOLUME")
1901   !
1902  Set_unit=32+Disc_unit
1903  Set_vol=64+Disc_vol
1904   !
1905   ! ******* send command message
1906  SEND Hpib;MTA UNL LISTEN Disc_addr SEC 101 DATA Set_unit,Set_vol,16,0,0,0,0,0,0,24,0,0,0,500,50,196,1 END UNL 
1907  REPEAT
1908  UNTIL BIT(PPOLL(Hpib),7-Disc_addr)
1909   !******** receive execution message
1910  SEND Hpib;MLA TALK Disc_addr SEC 110
1911  ENTER Hpib USING "-K";Disc$
1912  SEND Hpib;UNT 
1913  REPEAT
1914  UNTIL BIT(PPOLL(Hpib),7-Disc_addr)
1915   !******** read status from reporting message
1916  SEND Hpib;MLA TALK Disc_addr SEC 112
1917  ENTER Hpib USING "-K";Status$
1918  SEND Hpib;UNT UNL 
1919   ! if read OK, then decode bad tracks
1920  IF Status$=CHR$(0) THEN 
1921    GOSUB Strip_table
1922    IF Num_bad>1 THEN GOSUB Sort_table
1923  ELSE
1924    Num_bad=0
1925  END IF
1926  SUBEXIT
1927   !
1928 Strip_table:   !
1929  MAT Bad_addr= (0)
1930  Num_bad=0
1931  Head_ptr=1
1932  Head_cnt=0
1933  WHILE Head_cnt<Num_heads
1934    Head=NUM(Disc$[Head_ptr;1])
1935    Logical_spares=NUM(Disc$[Head_ptr+4;1])
1936    IF Logical_spares>0 THEN 
1937      Cyl_start=Head_ptr+5
1938      Head_ptr=Head_ptr+5+Logical_spares*3
1939      FOR Counter=1 TO Logical_spares
1940        Num_bad=Num_bad+1
1941        Bad_cyl=Cyl_start+(Counter-1)*3
1942        Cyl_addr=NUM(Disc$[Bad_cyl;1])*256+NUM(Disc$[Bad_cyl+1;1])
1943        Bad_addr(Num_bad)=((Cyl_addr*Num_heads)+Head)*Num_sectors*256
1944      NEXT Counter
1945    ELSE
1946      Head_ptr=Head_ptr+5
1947    END IF
1948    Head_cnt=Head_cnt+1
1949  END WHILE
1950  RETURN 
1951   !
1952 Sort_table:   !
1953   ! bubble sort bad segment table
1954  REPEAT
1955    Swap=0
1956    FOR Counter=1 TO Num_bad-1
1957      IF Bad_addr(Counter)>Bad_addr(Counter+1) THEN 
1958        Temp=Bad_addr(Counter)
1959        Bad_addr(Counter)=Bad_addr(Counter+1)
1960        Bad_addr(Counter+1)=Temp
1961        Swap=1
1962      END IF
1963    NEXT Counter
1964  UNTIL NOT Swap
1965  RETURN 
1966 SUBEND
1967  !
1968  !
1969 Test_sectors:SUB Test_sectors
1970  DIM Address(1:100),Loops(1:100)
1971  Total_loops=100.
1972  Block_size=1024.
1973  Num_modules=4.
1974  Scan_size=Block_size*Num_modules*2.
1975  CALL Thru_sector_tbl(Total_loops,Scan_size,Address(*),Loops(*))
1976  IF Loops(1)>0 THEN 
1977    PRINT "ADDRESS (BYTES)  NUM_SCANS"
1978    FOR I=1 TO SIZE(Loops,1)
1979      PRINT Address(I),Loops(I)
1980    NEXT I
1981  ELSE
1982    PRINT "NO ADDRESSES RETURNED"
1983  END IF
1984 SUBEND
1985  ! PAGE -> 
1986  !-----------------------------------------------------------------------
1987 Appl_help:SUB Appl_help
1988    ! This subprogram has a series of 'help screens' to give the user some
1989    ! quick information about the system...It is NOT meant to be a
1990    ! substitute for other documentation.
1991  ALLOCATE A$[160]
1992  RESTORE Page1
1993  GOSUB Show_page
1994  RESTORE Page2
1995  GOSUB Show_page
1996  RESTORE Page3
1997  GOSUB Show_page
1998  RESTORE Page4
1999  GOSUB Show_page
2000  RESTORE Page5
2001  GOSUB Show_page
2002  RESTORE Page6
2003  GOSUB Show_page
2004  SUBEXIT
2005 Show_page:!
2006  READ A$
2007  User_clr_scr
2008  WHILE A$<>"***END***"
2009    OUTPUT CRT;A$
2010    READ A$
2011  END WHILE
2012  OUTPUT KBD USING "#,K";"ÿ#Yÿ<"
2013  INPUT "Type 'Y' to continue, anything else to leave...",A$
2014  IF UPC$(A$[1;1])<>"Y" THEN SUBEXIT
2015  RETURN 
2016 Page1:   !
2017  DATA "              Help for Through-put Application"
2018  DATA ""
2019  DATA "This is the Through-put Application for the HP3565S system."
2020  DATA "In it you can do through-puts of data from up to 63 input modules"
2021  DATA "to a BDAT file on a CS-80 disc drive on the HP-IB.  The actual"
2022  DATA "through-put of data is controlled by the HP35651A Interface module,"
2023  DATA "and additional data about the setup and parameters of the system are"
2024  DATA "stored on the file by the through-put application program."
2025  DATA "WARNING: Connect only the host, HP-IB module and disc to this"
2026  DATA "HP-IB interface. See documentation."
2027  DATA ""
2028  DATA "The Configuration subprograms are called on power-up and have already"
2029  DATA "been used to assign labels to the modules in your system, and to"
2030  DATA "specify which modules will be active.  If you haven't done this and"
2031  DATA "you want to, use the EXIT key and then the CONFIG key to enter the"
2032  DATA "Configuration Menu.  Modules that are inactive are treated as though"
2033  DATA "they are not in the system at all."
2034  DATA "***END***"
2035 Page2:   !
2036  DATA "              Help for Through-put Application--Page 2"
2037  DATA ""
2038  DATA "There are 2 sets of softkeys associated with the through-put"
2039  DATA "application.  The first set, the THRUPUT keys, are used to"
2040  DATA "setup and start a through-put to a disc.  These keys appear"
2041  DATA "on power-up.  The second set of keys, the POST THRUPUT keys,"
2042  DATA "can be accessed by pressing the POST THRUPUT key in the"
2043  DATA "THRUPUT softkeys menu.  They are used to plot data once it"
2044  DATA "is on a disc."
2045  DATA ""
2046  DATA "There are three keys that are used to set up a measurement:"
2047  DATA "SOURCE SETUP, INPUT SETUP, and MEASURE SETUP."
2048  DATA 
2049  DATA "The SOURCE SETUP key is used to set up source modules. When the"
2050  DATA "system is first powered up, all source modules are OFF.  Source"
2051  DATA "modules not selected as being 'OFF' are started upon leaving the"
2052  DATA "SOURCE SETUP.   However, if the source is in a trigger mode other"
2053  DATA "than off, it may not start until a trigger is received."
2054  DATA "***END***"
2055 Page3:   !
2056  DATA "         Help for Through-put Application - Page 3"
2057  DATA ""
2058  DATA "The INPUT SETUP key is used to setup input modules."
2059  DATA "When the system powers up, one input module will be in"
2060  DATA "SEND trigger mode, and the others will be in RECEIVE trigger"
2061  DATA "mode.  At least one module (input or source) should normally"
2062  DATA "be in SEND trigger mode, so that the system will trigger."
2063  DATA "The inputs start out at range 0 dBVp, and will usually"
2064  DATA "need to have their ranges changed to appropriate levels."
2065  DATA "The Autorange function is useful if the source module is"
2066  DATA "already going, but it takes at least 20 seconds, and will"
2067  DATA "not always work correctly if the source is in a burst or"
2068  DATA "pulse mode."
2069  DATA "***END***"
2070 Page4:   !
2071  DATA "         Help for Through-put Application - Page 4"
2072  DATA ""
2073  DATA "The MEASURE SETUP key is used to change parameters of the"
2074  DATA "through-put, as well as information about the through-put"
2075  DATA "disc drive.  Disc HP-IB address, unit and volume numbers,"
2076  DATA "and the name of the current Through-put file, can be changed"
2077  DATA "here.  Note that if there are no legal Through_put files of sufficient"
2078  DATA "size there will be no selection of file name possible."
2079  DATA "file name possible.   "
2080  DATA ""
2081  DATA "The global measurement parameters of input module frequency"
2082  DATA "span, center frequency, zoom mode, and trigger delay may be"
2083  DATA "set here.  Note that only values allowed by the hardware modules"
2084  DATA "can be entered on the spread sheet. Other values will be either"
2085  DATA "ignored or rounded."
2086  DATA "The START key can be used to start a through-put, if a legal"
2087  DATA "through-put file is available."
2088  DATA "***END***"
2089 Page5:  !
2090  DATA "         Help for Through-put Application - Page 5"
2091  DATA ""
2092  DATA "             Creating The Through-put File"
2093  DATA "This application does not create the Through-put file.  To create a"
2094  DATA "Through-put file, Pause this program and Execute a CREATE BDAT commmand."
2095  DATA "The file must have 256 byte records, and the first 296 records will be"
2096  DATA "used to store setup information.  The rest of the file is available to "
2097  DATA "store through-put data at 2 bytes per sample.  For example,"
2098  DATA "        CREATE BDAT ""TDATA :CS80,704"",4096,256"
2099  DATA "would create a 1 MByte file which could store 950 512-sample blocks."
2100  DATA ""
2101  DATA "If valid through-put data is present in the current file,"
2102  DATA "the POST THRUPUT key will appear at key 5.  Pressing this key"
2103  DATA "will change key definitions for the post through-put processing."
2104  DATA  "***END***"
2105 Page6: !
2106  DATA "         Help for Through-put Application - Page 6"
2107  DATA ""
2108  DATA "The DISPLAY SETUP key under the POST THRUPUT menu will display"
2109  DATA "the display spread sheet, which allows selection of which"
2110  DATA "channels of the through-put will be plotted, in what order, and"
2111  DATA "with what values for their x and y axes.  Note that there are"
2112  DATA "always 2 plot blocks plotted, and the x axis of any plot must"
2113  DATA "start a multiple of a plot block.  Other values of PLOT BLK START"
2114  DATA "will be rounded appropriately"
2115  DATA ""
2116  DATA "The PLOT BLK SIZE key asks for a power-of-2 block size in"
2117  DATA "words for the plots."
2118  DATA "The <PREV REC and NEXT REC> keys are used to move to the next or"
2119  DATA "previous plot block depending on the function of key 2 (ALL PLOTS or"
2120  DATA "FIRST PLOT).  If FIRST PLOT is selected, the program will just"
2121  DATA "increment or decrement the start of the first plot as found in the"
2122  DATA "DISPLAY spread sheet (the upper-left-most plot).  Note that this has"
2123  DATA "the same effect as changing the PLOT BLK START column(s) in the spread sheet."
2124  DATA "***END***"
2125 Page7:   !
2126 SUBEND
2127  !
2128  ! PAGE ->
2129  !*************************************************************************
2130 Post_post:SUB Post_post
2131 !
2132 ! Defines the Common blocks for the Post through-put display spreadsheet.
2133  COM /Post_spread1/ Box$(1:10,1:17)[40],Row,Col,Start_row
2134  COM /Post_spread2/ Title$(1:10,0:2)[40],Prompt$(1:10)[80],Col_width(1:10)
2135  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
2136  COM /Post_spread4/ Choices$(1:6,1:64)[40],Num_choices(1:6)
2137  COM /Post_choice/ Plot_choice(1:9,1:6)
2138 SUBEND
2139  ! PAGE -> 
2140  !************************************************************************
2141 Meas_meas:SUB Meas_meas
2142  !
2143  ! Defines the common blocks for the measurement spreadsheet.
2144  COM /Meas_sprd/ Box$(1:2,1:15)[40],Title$(1:2,0:2)[40],Prompt$(1:15)[80]
2145  COM /Meas_sprd_num/ Col_width(1:2),Modify_col,INTEGER Max_row,Max_col
2146  COM /Meas_mod_labels/ Srce_labels$(1:63)[20],Inpt_labels$(1:63)[20]
2147  COM /Meas_mod_counts/ Srce_count,Inpt_count,Current_srce,Current_inpt
2148  COM /Meas_cmnd/ Cmnd$(2:15)[20],Def_value$(2:15)[20]
2149  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
2150  COM /Meas_file_info/ File_name$(1:63)[10],File_length(1:63),Rec_size(1:63),Start_addr(1:63),Num_files
2151  Meas_powerup
2152 SUBEND
2153  ! PAGE -> 
2154  !************************************************************************
2155 Meas_powerup:SUB Meas_powerup
2156  !
2157  !Initializes constants associated with the Measurement spreadsheet.
2158  ! This includes such things as row titles, prompts, defaults, etc.
2159  !
2160  COM /Meas_sprd/ Box$(*),Title$(*),Prompt$(*)
2161  COM /Meas_sprd_num/ Col_width(*),Modify_col,INTEGER Max_row,Max_col
2162  COM /Meas_mod_counts/ Srce_count,Inpt_count,Current_srce,Current_inpt
2163  COM /Meas_cmnd/ Cmnd$(*),Def_value$(*)
2164  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
2165  DIM Box1$[60],Box2$[60],Prompt1$[100]
2166    !
2167  Disc_header=1
2168    !
2169  Max_col=2
2170  Modify_col=2
2171    !
2172  RESTORE Meas_data
2173  Row=Disc_header+1
2174  REPEAT
2175    READ Box$(2,Row),Box$(1,Row),Prompt$(Row)
2176    Row=Row+1
2177  UNTIL Box$(2,Row-1)=""
2178    !
2179  Cmnd_header=Row-1
2180  REPEAT
2181    READ Cmnd$(Row),Def_value$(Row),Box$(1,Row),Prompt$(Row)
2182    Row=Row+1
2183  UNTIL Cmnd$(Row-1)=""
2184    !
2185  Row=Row-1
2186  Info_start=Row
2187  LOOP
2188    READ Box2$,Box1$,Prompt1$
2189  EXIT IF Box2$=""
2190    Box$(2,Row)=Box2$
2191    Box$(1,Row)=Box1$
2192    Prompt$(Row)=Prompt1$
2193    Row=Row+1
2194  END LOOP
2195  Max_row=Row-1
2196    !
2197  Hp_ib_r=Disc_header+1
2198  Unit_r=Disc_header+2
2199  Vol_r=Disc_header+3
2200  File_r=Disc_header+4
2201  Bsiz_r=Cmnd_header+1
2202  Span_r=Cmnd_header+2
2203  Zoom_r=Cmnd_header+3
2204  Cfreq_r=Cmnd_header+4
2205  Tdly_r=Cmnd_header+5
2206  Cmode_r=Info_start
2207  Tmode_r=Info_start+1
2208  Len_r=Info_start+2
2209  Loops_r=Info_start+3
2210    !
2211  Current_inpt=1
2212  Title$(1,0)="THROUGH-PUT MEASUREMENT SET-UP"
2213  Title$(1,1)="Item"
2214  Title$(1,2)=""
2215  Title$(2,1)="Value"
2216  Title$(2,2)=""
2217  Col_width(1)=40
2218  Col_width(2)=20
2219    !
2220  Box$(1,Disc_header)="****** Through-put Disc Info ******"
2221  Box$(1,Cmnd_header)="****** Setups for All Inputs ******"
2222  Box$(2,Disc_header)=""
2223  Box$(2,Cmnd_header)=""
2224  Row=2                !reset cursor to top row for 1st time thru
2225  SUBEXIT
2226 Meas_data:!
2227    !DISC INFO ROWS
2228  DATA "4",  "Disc HP-IB Address      ->"
2229  DATA "Enter HP-IB Address of Through-put disc (0-31)"
2230    !
2231  DATA "0",  "Disc Unit Number        ->"
2232  DATA "Enter Unit Number of Disc for Through-puts (0-14)"
2233    !
2234  DATA "0",  "Disc Volume Number      ->"
2235  DATA "Enter Volume Number on Disc for Through-puts (0-7)"
2236    !
2237  DATA " ",   "Through-put File Name   ->"
2238  DATA "Enter Name of BDAT file to use for Through-puts"
2239  DATA "","",""
2240    !
2241    !COMMAND ROWS
2242  DATA "TRANSFER SIZE",      "1024","Through-put Transfer Size  ->"
2243  DATA "Enter Through-put transfer size (4, 8, ..., 8192)"
2244    !
2245  DATA "SPAN",             "51200", "Frequency Span             ->"
2246  DATA "Enter Span in Hz (0.195,0.39,...,100,200,...,102400)"
2247    !
2248  DATA "ZOOM MODE", "OFF",          "Zoom Mode                  ->"
2249  DATA "Enter Zoom Mode (On or Off)"
2250    !
2251  DATA "CENTER FREQ", "25600",      "Center Frequency           ->"
2252  DATA "Enter Center Frequency for Zoom Mode (Hz)"
2253    !
2254  DATA "TRIGGER DELAY",    "0",     "Trigger Delay              ->"
2255  DATA "Enter Trigger Delay in samples (+/- N)"
2256    !
2257  DATA "","","",""
2258    !
2259 ! INFO ROWS  (No Command)
2260  DATA "Cont --> Stop",  "Data collection mode            ->"
2261  DATA "Enter collection mode (Block, Cont --> Stop, Cont-->Switch to blk)"
2262  DATA "Immediate",  "Through-put Trigger Mode        ->"
2263  DATA "Enter Trigger mode (Immediate, First Block, Each block)"
2264    !
2265  DATA "39.0625","Through-put length (mSec)       ->"
2266  DATA "Amount of data to through-put from each module (mSec)"
2267    !
2268  DATA "5",      "Number of scans in through-put  ->"
2269  DATA "Enter number of blocks to take from each module"
2270  DATA "","",""
2271 SUBEND
2272  ! PAGE -> 
2273  !************************************************************************
2274 Meas_init:SUB Meas_init
2275 !
2276 ! Called to pick some startup values for measurement spread_sheet entries.
2277 !
2278  COM /Meas_sprd/ Box$(*),Title$(*),Prompt$(*)
2279  COM /Meas_mod_labels/ Srce_labels$(*),Inpt_labels$(*)
2280  COM /Meas_mod_counts/ Srce_count,Inpt_count,Current_srce,Current_inpt
2281  COM /Meas_cmnd/ Cmnd$(*),Def_value$(*)
2282  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
2283  COM /Meas_file_info/ File_name$(*),File_length(*),Rec_size(*),Start_addr(*),Num_files
2284    !
2285    ! LOOK AT DISC, PICK THE FIRST BDAT FILE FOR A SPREADSHEET ENTRY.
2286  Meas_do_cat
2287  Meas_init_file
2288    !
2289    ! Get Input labels
2290    !
2291  Cnfg_labels("ALL INPUT",Inpt_labels$(*),Inpt_count)
2292  IF Inpt_count<1 THEN 
2293    User_error("Can't do THRU_MEAS without an input")
2294  END IF
2295    !
2296    ! Setup Inputs, then read back from current input
2297  FOR Row=Cmnd_header+1 TO Info_start-1
2298    IF Cmnd$(Row)="TRANSFER SIZE" THEN   !SET TBLK AND BSIZ THE SAME
2299      Tmp$="BLOCK SIZE"
2300      Inpt_cmd("ALL INPUT",Tmp$,Def_value$(Row))
2301      Tmp$=Cmnd$(Row)
2302      Inpt_cmd("ALL INPUT",Tmp$,Def_value$(Row))
2303      Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(Current_inpt),Tmp$))
2304    ELSE
2305      Inpt_cmd("ALL INPUT",Cmnd$(Row),Def_value$(Row))
2306      Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(Current_inpt),Cmnd$(Row)))
2307    END IF
2308  NEXT Row
2309  Row=2    !initialize cursor row
2310    !
2311 SUBEND
2312  ! PAGE -> 
2313  !************************************************************************
2314 Meas_spread:SUB Meas_spread(Changed)
2315  !
2316  ! The actual measurement spread sheet.  Called to put up the spreadsheet,
2317  ! and parse entered values for validity.
2318  !
2319  ! OUTPUTS: Changed:  =1 when any value in spread sheet changes.
2320  !
2321  COM /Meas_sprd/ Box$(*),Title$(*),Prompt$(*)
2322  COM /Meas_sprd_num/ Col_width(*),Modify_col,INTEGER Max_row,Max_col
2323  COM /Meas_mod_labels/ Srce_labels$(*),Inpt_labels$(*)
2324  COM /Meas_mod_counts/ Srce_count,Inpt_count,Current_srce,Current_inpt
2325  COM /Meas_cmnd/ Cmnd$(*),Def_value$(*)
2326  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
2327  COM /Meas_file_info/ File_name$(*),File_length(*),Rec_size(*),Start_addr(*),Num_files
2328  DIM New_entry$[160]
2329  INTEGER Done,Dummy,Found_it
2330  Changed=0
2331    !
2332    ! Define softkeys.  Keys 1 through 4 are 'firmkeys'
2333    !
2334  ON KEY 5 LABEL "" CALL User_key5isr
2335  ON KEY 6 LABEL "" CALL User_key6isr
2336  ON KEY 7 LABEL FNUser_keylabel$("Prev") CALL User_key7isr
2337  ON KEY 8 LABEL FNUser_keylabel$("Next") CALL User_key8isr
2338    !
2339  User_clr_scr
2340    !
2341    ! Now call spreadsheet.
2342    !
2343  Col=2
2344  Start_row=1
2345  Done=0
2346  REPEAT
2347    User_spread(Box$(*),Title$(*),Prompt$(*),New_entry$,Col_width(*),Modify_col,Col,Row,Start_row)
2348    SELECT FNUser_check_key
2349    CASE 0
2350      GOSUB Meas_new_entry
2351    CASE 5,6
2352      BEEP 
2353      Dummy=FNUser_get_key
2354    CASE 7       ! Prev
2355      Dummy=FNUser_get_key
2356      GOSUB Meas_prev
2357    CASE 8       ! Next
2358      Dummy=FNUser_get_key
2359      GOSUB Meas_next
2360    CASE ELSE    ! A softkey, but not one of mine.
2361      Done=1
2362    END SELECT
2363  UNTIL Done
2364  User_clr_scr
2365  SUBEXIT
2366    !
2367 Meas_new_entry:!
2368  Changed=1
2369  SELECT Row
2370    !
2371  CASE Hp_ib_r
2372    ON ERROR GOTO Meas_bad_addr
2373    Tmp=INT(VAL(New_entry$))
2374    IF Tmp<32 AND Tmp>=0 THEN 
2375      Box$(2,Row)=VAL$(Tmp)
2376      Meas_do_cat
2377      Meas_init_file
2378    END IF
2379 Meas_bad_addr: !
2380    OFF ERROR 
2381    !
2382  CASE Unit_r    ! 0 to 14 valid for a  CS-80 disc
2383    ON ERROR GOTO Meas_bad_unit
2384    Tmp=INT(VAL(New_entry$))
2385    IF Tmp<15 AND Tmp>=0 THEN Box$(2,Row)=VAL$(Tmp)
2386    Meas_do_cat
2387    Meas_init_file
2388 Meas_bad_unit:!
2389    OFF ERROR 
2390    !
2391  CASE Vol_r     ! 0 TO 7 FOR A CS-80 DISC.
2392    ON ERROR GOTO Meas_bad_vol
2393    Tmp=INT(VAL(New_entry$))
2394    IF Tmp<8 AND Tmp>=0 THEN Box$(2,Row)=VAL$(Tmp)
2395 Meas_bad_vol:!
2396    Meas_do_cat
2397    Meas_init_file
2398    OFF ERROR 
2399    !
2400  CASE File_r
2401    Meas_do_cat
2402    Lib_match1(New_entry$,File_name$(*),Found,Tmp)
2403    IF NOT Found THEN 
2404      User_error(New_entry$&" - FILE NOT FOUND ON THROUGH-PUT DISC")
2405    ELSE
2406      Box$(2,Row)=TRIM$(File_name$(Tmp))
2407      GOSUB Meas_check_eof
2408    END IF
2409  CASE Cmnd_header+1 TO Info_start-1   ! It's a global input setup command
2410    Changed=1
2411    IF Row=Bsiz_r THEN   ! It's the BLOCK SIZE command
2412      Box$(2,Bsiz_r)=New_entry$
2413      ON ERROR GOTO Meas_bad_bsiz
2414      Inpt_cmd("ALL INPUT","BLOCK SIZE",Box$(2,Bsiz_r))
2415      Inpt_cmd("ALL INPUT","TRANSFER SIZE",Box$(2,Bsiz_r))
2416      Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"BLOCK SIZE"))
2417      OFF ERROR 
2418      GOSUB Meas_new_bsiz
2419 Meas_bad_bsiz:!
2420      OFF ERROR 
2421    ELSE
2422      IF Row=Tdly_r THEN 
2423        Box$(2,Row)=New_entry$
2424        Inpt_cmd("ALL INPUT",Cmnd$(Row),Box$(2,Row))
2425        Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),Cmnd$(Row)))
2426        GOSUB Meas_chk_tdly
2427      ELSE
2428        Inpt_cmd("ALL INPUT",Cmnd$(Row),New_entry$)
2429        Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),Cmnd$(Row)))
2430        IF Row=Span_r THEN GOSUB Meas_new_span
2431        IF Row=Zoom_r THEN GOSUB Meas_chk_tdly
2432      END IF
2433    END IF
2434  CASE Cmode_r   !BLock, Cont-->Switch to blk, Cont --> Stop
2435    IF POS(UPC$(New_entry$),"ST") THEN 
2436      Box$(2,Row)="Cont --> Stop"
2437    ELSE
2438      IF POS(UPC$(New_entry$),"BL") THEN 
2439        Box$(2,Row)="Block"
2440      ELSE
2441        IF POS(UPC$(New_entry$),"SW") THEN 
2442          Box$(2,Row)="Cont-->Switch to blk"
2443        END IF
2444      END IF
2445    END IF
2446  CASE Tmode_r
2447    IF POS(UPC$(New_entry$),"IM") THEN 
2448      Box$(2,Row)="Immediate"
2449    ELSE
2450      IF POS(UPC$(New_entry$),"FI") THEN 
2451        Box$(2,Row)="First block"
2452      ELSE
2453        IF POS(UPC$(New_entry$),"EA") THEN 
2454          Box$(2,Row)="Each block"
2455        END IF
2456      END IF
2457    END IF
2458  CASE Len_r
2459    ON ERROR GOTO Meas_bad_len
2460    Tmp=INT(VAL(New_entry$))
2461    IF Tmp>0 THEN 
2462      Box$(2,Row)=VAL$(Tmp)
2463      GOSUB Meas_new_len
2464    END IF
2465 Meas_bad_len: !
2466    OFF ERROR 
2467  CASE Loops_r
2468    ON ERROR GOTO Meas_bad_loops
2469    Tmp=INT(VAL(New_entry$))
2470    IF Tmp>0 THEN 
2471      Box$(2,Row)=VAL$(Tmp)
2472      GOSUB Meas_new_loops
2473    END IF
2474 Meas_bad_loops:!
2475    OFF ERROR 
2476  CASE ELSE
2477    BEEP 
2478  END SELECT
2479  RETURN 
2480    !
2481 Meas_prev:!
2482  Changed=1
2483  SELECT Row
2484  CASE Bsiz_r         !TRANSFER SIZE
2485    Inpt_cmd("ALL INPUT","BLOCK SIZE",VAL$(VAL(Box$(2,Row))/2))
2486    Inpt_cmd("ALL INPUT","TRANSFER SIZE",VAL$(VAL(Box$(2,Row))/2))
2487    Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"BLOCK SIZE"))
2488    GOSUB Meas_new_bsiz
2489  CASE Span_r     !SPAN
2490    IF VAL(Box$(2,Row))<.2 THEN Box$(2,Row)="204800"   !wraparaound
2491    Inpt_cmd("ALL INPUT","SPAN",VAL$(.5*VAL(Box$(2,Row))))
2492    Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"SPAN"))
2493    GOSUB Meas_new_span
2494  CASE Zoom_r    !on/off
2495    GOSUB Meas_toggle
2496  CASE Cfreq_r
2497    Inpt_cmd("ALL INPUT",Cmnd$(Row),VAL$(VAL(Box$(2,Row))/1.2))
2498    Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"CENTER FREQ"))
2499  CASE Cmode_r   !blk/cont
2500    SELECT UPC$(Box$(2,Row))
2501    CASE "BLOCK"
2502      Box$(2,Row)="Cont-->Switch to blk"
2503    CASE "CONT --> STOP"
2504      Box$(2,Row)="Block"
2505    CASE "CONT-->SWITCH TO BLK"
2506      Box$(2,Row)="Cont --> Stop"
2507    END SELECT
2508  CASE Hp_ib_r
2509    IF VAL(Box$(2,Row))=0 THEN Box$(2,Row)="32"
2510    Box$(2,Row)=VAL$(VAL(Box$(2,Row))-1)
2511    Meas_do_cat
2512    Meas_init_file
2513  CASE Unit_r
2514    IF VAL(Box$(2,Row))=0 THEN Box$(2,Row)="15"
2515    Box$(2,Row)=VAL$(VAL(Box$(2,Row))-1)
2516    Meas_do_cat
2517    Meas_init_file
2518  CASE Vol_r
2519    IF VAL(Box$(2,Row))=0 THEN Box$(2,Row)="8"
2520    Box$(2,Row)=VAL$(VAL(Box$(2,Row))-1)
2521    Meas_do_cat
2522    Meas_init_file
2523  CASE File_r
2524    IF Num_files>1 THEN 
2525      Lib_match1(Box$(2,File_r),File_name$(*),Found,Tmp)
2526      IF Tmp=1 THEN Tmp=Num_files+1
2527      Box$(2,Row)=File_name$(Tmp-1)
2528      GOSUB Meas_check_eof
2529    END IF
2530  CASE Tmode_r
2531    SELECT UPC$(Box$(2,Row))
2532    CASE "IMMEDIATE"
2533      Box$(2,Row)="Each block"
2534    CASE "FIRST BLOCK"
2535      Box$(2,Row)="Immediate"
2536    CASE "EACH BLOCK"
2537      Box$(2,Row)="First block"
2538    END SELECT
2539  CASE Len_r
2540    Box$(2,Row)=VAL$(.5*VAL(Box$(2,Row)))
2541    GOSUB Meas_new_len
2542  CASE Loops_r
2543    IF VAL(Box$(2,Row))=1 THEN Box$(2,Row)="2"
2544    Box$(2,Row)=VAL$(INT(VAL(Box$(2,Row))-1))
2545    GOSUB Meas_new_loops
2546  END SELECT
2547  RETURN 
2548    !
2549 Meas_next:!
2550  Changed=1
2551  SELECT Row
2552  CASE Bsiz_r         !TRANSFER SIZE
2553    Inpt_cmd("ALL INPUT","BLOCK SIZE",VAL$(VAL(Box$(2,Row))*2))
2554    Inpt_cmd("ALL INPUT","TRANSFER SIZE",VAL$(VAL(Box$(2,Row))*2))
2555    Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"BLOCK SIZE"))
2556    GOSUB Meas_new_bsiz
2557  CASE Span_r     !SPAN
2558    IF VAL(Box$(2,Row))>51200 THEN Box$(2,Row)=".09765625"   !wraparaound
2559    Inpt_cmd("ALL INPUT","SPAN",VAL$(2.*VAL(Box$(2,Row))))
2560    Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"SPAN"))
2561    GOSUB Meas_new_span
2562  CASE Zoom_r    !on/off
2563    GOSUB Meas_toggle
2564  CASE Cfreq_r
2565    Inpt_cmd("ALL INPUT",Cmnd$(Row),VAL$(1.2*VAL(Box$(2,Row))))
2566    Box$(2,Row)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"CENTER FREQ"))
2567  CASE Cmode_r   !blk/cont
2568    SELECT UPC$(Box$(2,Row))
2569    CASE "BLOCK"
2570      Box$(2,Row)="Cont --> Stop"
2571    CASE "CONT --> STOP"
2572      Box$(2,Row)="Cont-->Switch to blk"
2573    CASE "CONT-->SWITCH TO BLK"
2574      Box$(2,Row)="Block"
2575    END SELECT
2576  CASE Hp_ib_r
2577    IF VAL(Box$(2,Row))=31 THEN Box$(2,Row)="-1"
2578    Box$(2,Row)=VAL$(VAL(Box$(2,Row))+1)
2579    Meas_do_cat
2580    Meas_init_file
2581  CASE Unit_r
2582    IF VAL(Box$(2,Row))=14 THEN Box$(2,Row)="-1"
2583    Box$(2,Row)=VAL$(VAL(Box$(2,Row))+1)
2584    Meas_do_cat
2585    Meas_init_file
2586  CASE Vol_r
2587    IF VAL(Box$(2,Row))=7 THEN Box$(2,Row)="-1"
2588    Box$(2,Row)=VAL$(VAL(Box$(2,Row))+1)
2589    Meas_do_cat
2590    Meas_init_file
2591  CASE File_r
2592    IF Num_files>1 THEN 
2593      Lib_match1(Box$(2,File_r),File_name$(*),Found,Tmp)
2594      IF Tmp=Num_files THEN Tmp=0
2595      Box$(2,Row)=File_name$(Tmp+1)
2596      GOSUB Meas_check_eof
2597    END IF
2598  CASE Tmode_r
2599    SELECT UPC$(Box$(2,Row))
2600    CASE "IMMEDIATE"
2601      Box$(2,Row)="First block"
2602    CASE "FIRST BLOCK"
2603      Box$(2,Row)="Each block"
2604    CASE "EACH BLOCK"
2605      Box$(2,Row)="Immediate"
2606    END SELECT
2607  CASE Len_r
2608    Box$(2,Row)=VAL$(2.*VAL(Box$(2,Row)))
2609    GOSUB Meas_new_len
2610  CASE Loops_r
2611    Box$(2,Row)=VAL$(INT(VAL(Box$(2,Row))+1))
2612    GOSUB Meas_new_loops
2613  END SELECT
2614  RETURN 
2615    !
2616 Meas_toggle:!
2617  SELECT Row
2618  CASE Zoom_r                  ! Toggle zoom mode on or off
2619    IF Box$(2,Row)="ON" THEN 
2620      Box$(2,Row)="OFF"
2621    ELSE
2622      Box$(2,Row)="ON"
2623    END IF
2624    Changed=1
2625    GOSUB Meas_chk_tdly
2626  END SELECT
2627  RETURN 
2628 Meas_new_bsiz:! ADJUST LENGTH AND NUM_LOOPS
2629  Block_size=VAL(Box$(2,Row))
2630  Span=VAL(Box$(2,Span_r))
2631  Thru_length=VAL(Box$(2,Len_r))*Span*2.56E-3
2632  Num_loops=MAX(INT(.9999+Thru_length/Block_size),1)
2633  Box$(2,Loops_r)=VAL$(Num_loops)
2634  Thru_length=Block_size*Num_loops
2635  Box$(2,Len_r)=VAL$(Thru_length/(Span*2.56E-3))
2636  GOSUB Meas_chk_tdly
2637  RETURN 
2638 Meas_check_eof:!
2639  !
2640  ! THIS ROUTINE CHECKS TO SEE IF THE PARAMETERS ARE SETUP CORRECTLY AS
2641  ! NOT TO OVERWRITE THE END OF THHE FILE. THE THREE PARAMETERS THAT
2642  ! AFFECT THE LENGTH OF THE FILE ARE THE FILENAME, NUMBER OF LOOPS, AND
2643  ! ACQUISITION TIME. IF ANY OF THE PARAMETERS CAUSE US TO OVERWRITE THE
2644  ! END OF THE FILE, THE NUMBER OF LOOPS WILL BE ADJUSTED BY THIS ROUTINE.
2645  ! IF A FILENAME IS NOT SPECIFIED, ANY PARAMETER CAN BE ENTERED.
2646  !
2647  ! SINCE A BAD SEGMENT TABLE IS NOT CURRENTLY GENERATED, THHERE WILL BE NO
2648  ! NEED TO WORRY ABOUT THE FILE LENGTH BEING LONGER THAN (LOOPS +2)*256   ES
2649  ! BYTES LONG.
2650  !
2651  Tmp$=Box$(2,File_r)
2652  Lib_match1(Tmp$,File_name$(*),Found,Tmp)
2653  IF Found THEN   ! A FILENAME IS SPECIFIED
2654    File_start_addr=FNMeas_thru_parm("START ADDR")
2655    Tmp_start_addr=File_start_addr+256.0*(8+288)
2656    Eof_addr=FNMeas_thru_parm("FILE SIZE")*256.0+File_start_addr
2657    Num_loops=VAL(Box$(2,Loops_r))
2658    Xfer_size=FNMeas_thru_parm("TRANSFER SIZE")
2659    IF Eof_addr<Tmp_start_addr+(Num_loops+2)*Xfer_size*2*Inpt_count THEN 
2660      Num_loops=INT((Eof_addr-Tmp_start_addr)/(Xfer_size*2*Inpt_count))-2
2661      IF Num_loops<0 THEN Num_loops=0
2662      Box$(2,Loops_r)=VAL$(Num_loops)
2663      Box$(2,Len_r)=VAL$(VAL(Box$(2,Bsiz_r))*Num_loops/(VAL(Box$(2,Span_r))*2.56E-3))
2664      User_error("FILESIZE TOO SHORT.  NUMBER OF THRUPUT LOOPS HAS BEEN CHANGED")
2665    END IF
2666  END IF
2667  RETURN 
2668  !
2669 Meas_new_len:!ADJUST NUM_LOOPS AND RE-CALC LENGTH TO MULTS OF BSIZE.
2670  Thru_length=INT(VAL(Box$(2,Span_r))*2.56*VAL(Box$(2,Len_r))/1000)       !mSEC->SAMP
2671  Num_loops=MAX(INT(.9999+Thru_length/VAL(Box$(2,Bsiz_r))),1)
2672  Box$(2,Loops_r)=VAL$(Num_loops)
2673  Box$(2,Len_r)=VAL$(VAL(Box$(2,Bsiz_r))*Num_loops/(VAL(Box$(2,Span_r))*2.56E-3))
2674  GOSUB Meas_check_eof
2675  RETURN 
2676 Meas_new_loops:!  ADJUST THRUPUT LENGTH WHEN NEW NUM_LOOPS.
2677  OFF ERROR 
2678  Thru_length=1.0*VAL(Box$(2,Bsiz_r))*VAL(Box$(2,Loops_r))
2679  Span=VAL(Box$(2,Span_r))
2680  Box$(2,Len_r)=VAL$(Thru_length/(Span*2.56E-3))
2681  GOSUB Meas_check_eof
2682  RETURN 
2683 Meas_new_span: !  ADJUST LENGTH (IN mSEC), KEEPING NUMBER OF SAMPLES SAME.
2684  Thru_length=1.0*VAL(Box$(2,Cmnd_header+1))*VAL(Box$(2,Loops_r))
2685  Span=VAL(Box$(2,Span_r))
2686  Box$(2,Len_r)=VAL$(Thru_length/(Span*2.56E-3))
2687  RETURN 
2688 Meas_chk_tdly: !  CHECK FOR ILLEGAL VALUES OF TRIGGER DELAY, AND FIX.
2689  Trig_dly_old=VAL(Box$(2,Tdly_r))
2690  IF Trig_dly_old<1-2*VAL(Box$(2,Bsiz_r)) THEN 
2691    User_error("PRE-TRIGGER MUST BE LESS THAN 2*BLOCK SIZE.  ADJUSTING TRIGGER DELAY")
2692    Trig_dly_old=2-2*VAL(Box$(2,Bsiz_r))
2693    Inpt_cmd("ALL INPUT","TRIG DELAY",VAL$(Trig_dly_old))
2694    Box$(2,Tdly_r)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"TRIG DELAY"))
2695  END IF
2696  IF TRIM$(Box$(2,Zoom_r))="ON" THEN   !ONLY EVEN N ALLOWED IN ZOOM.
2697    IF Trig_dly_old/2<>Trig_dly_old DIV 2 THEN 
2698      User_error("ONLY EVEN VALUES OF TRIGGER DELAY ALLOWED IN ZOOM, ADJUSTING ENTRY..")
2699      Trig_dly_old=2*(Trig_dly_old DIV 2)
2700      Inpt_cmd("ALL INPUT","TRIG DELAY",VAL$(Trig_dly_old))
2701      Box$(2,Tdly_r)=TRIM$(FNInpt_rsp$(Inpt_labels$(1),"TRIG DELAY"))
2702    END IF
2703  END IF
2704  RETURN 
2705 SUBEND
2706  ! PAGE -> 
2707  !************************************************************************
2708  !
2709  !     Now some subprograms for the application to use
2710  !
2711  !************************************************************************
2712 Meas_thru_parm:DEF FNMeas_thru_parm(Parm_name$)
2713  !
2714  ! FNmeas_thru_parm returns the parameter specified by Parm_name$, as
2715  !  set up by the MEAS spread sheet.  Thus Meas_spread (or Meas_init)
2716  !  must be called first.
2717  !
2718  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
2719  COM /Meas_sprd/ Box$(*),Title$(*),Prompt$(*)
2720  COM /Meas_file_info/ File_name$(*),File_length(*),Rec_size(*),Start_addr(*),Num_files
2721  !
2722  SELECT Parm_name$
2723  CASE "DISC ADDRESS","DISC HP-IB","DISC ADDR"
2724    RETURN VAL(Box$(2,Hp_ib_r))
2725  CASE "DISC UNIT"
2726    RETURN VAL(Box$(2,Unit_r))
2727  CASE "DISC VOLUME","DISC VOL"
2728    RETURN VAL(Box$(2,Vol_r))
2729  CASE "LENGTH","THRUPUT LENGTH"
2730    RETURN VAL(Box$(2,Len_r))
2731  CASE "NUMBER LOOPS"
2732    RETURN VAL(Box$(2,Loops_r))
2733  CASE "FALLOUT"
2734    SELECT UPC$(Box$(2,Cmode_r))
2735    CASE "CONT-->SWITCH TO BLK"
2736      RETURN 1
2737    CASE ELSE
2738      RETURN 0
2739    END SELECT
2740  CASE "TRIGGER"
2741    SELECT UPC$(Box$(2,Tmode_r))
2742    CASE "IMMEDIATE"
2743      RETURN 1
2744    CASE "FIRST BLOCK"
2745      RETURN 2
2746    CASE "EACH BLOCK"
2747      RETURN 3
2748    END SELECT
2749  CASE "TRANSFER MODE"
2750    SELECT UPC$(Box$(2,Cmode_r))
2751    CASE "BLOCK"
2752      RETURN 0
2753    CASE ELSE
2754      RETURN 1
2755    END SELECT
2756  CASE "TRANSFER SIZE"
2757    RETURN VAL(Box$(2,Bsiz_r))
2758  CASE "ZOOM","ZOOM MODE"
2759    SELECT Box$(2,Zoom_r)
2760    CASE "ON"
2761      RETURN 1
2762    CASE "OFF"
2763      RETURN 0
2764    END SELECT
2765  CASE "TRIG DELAY","TRIGGER DELAY"
2766    RETURN VAL(Box$(2,Tdly_r))
2767  CASE "SPAN"
2768    RETURN VAL(Box$(2,Span_r))
2769  CASE "CENTER","CENTER FREQ","CENTER FREQUENCY"
2770    RETURN VAL(Box$(2,Cfreq_r))
2771  CASE "START ADDR","FILE START ADDRESS"
2772    Lib_match1(Box$(2,File_r),File_name$(*),Found,File_ptr)
2773    IF Found THEN 
2774      RETURN 256.0*(Start_addr(File_ptr))
2775    ELSE
2776      User_stop("NO MATCH FOR FILE:"&Box$(2,File_r)&" IN MEAS_THRU_PARM")
2777      RETURN -1
2778    END IF
2779  CASE "FILE SIZE","NUMBER RECORDS"
2780    Lib_match1(Box$(2,File_r),File_name$(*),Found,File_ptr)
2781    IF Found THEN 
2782      RETURN File_length(File_ptr)
2783    ELSE
2784      User_stop("NO MATCH FOR FILE:"&Box$(2,File_r)&" IN MEAS_THRU_PARM")
2785    END IF
2786  CASE "RECORD SIZE"
2787    Lib_match1(Box$(2,File_r),File_name$(*),Found,File_ptr)
2788    IF Found THEN 
2789      RETURN Rec_size(File_ptr)
2790    ELSE
2791      User_stop("NO MATCH FOR FILE:"&Box$(2,File_r)&" IN MEAS_THRU_PARM")
2792    END IF
2793  CASE ELSE
2794    User_error("ILLEGAL ARG FOR Meas_thru_parm: "&Parm_name$)
2795    RETURN 0
2796  END SELECT
2797 FNEND
2798  ! PAGE -> 
2799  !************************************************************************
2800 Post_spread_set:SUB Post_spread_set(Tr_name$(*),Num_traces,Tr_type$(*),Num_types)
2801  !This sub sets up the display spread sheet.  It should be called
2802  !before Post_spread and whenever there is a configuration change.
2803  !It defines the spread sheet titles, etc which are stored in COM.
2804  !Columns for "Active" "Trace Name","Trace type" "Y min","Y max"
2805  !and "Plot Blk Start" are standard
2806  !
2807  COM /Post_spread1/ Box$(*),Row,Col,Start_row
2808  COM /Post_spread2/ Title$(*),Prompt$(*),Col_width(*)
2809  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
2810  COM /Post_spread4/ Choices$(*),Num_choices(*)
2811 !
2812  Num_categories=2             !channel name and trace_type cols.
2813  Max_col=5+Num_categories     !7 for num, active, name, type, y min, y max, x start
2814    !
2815    !
2816    !For each category, count the number of choices
2817  REDIM Num_choices(1:Num_categories)    !for name and type
2818  Num_choices(1)=Num_traces
2819  Num_choices(2)=Num_types
2820    !
2821    !copy list of choices into common
2822  REDIM Choices$(1:Num_categories,1:MAX(Num_choices(*)))
2823  Category_num=1
2824  FOR Choice_num=1 TO Num_choices(Category_num)
2825    Choices$(Category_num,Choice_num)=Tr_name$(Choice_num)
2826  NEXT Choice_num
2827  Category_num=2
2828  FOR Choice_num=1 TO Num_choices(Category_num)
2829    Choices$(Category_num,Choice_num)=Tr_type$(Choice_num)
2830  NEXT Choice_num
2831    !
2832    !figure out how many rows should be displayed
2833  Max_row=1
2834  FOR Category_num=1 TO Num_categories
2835    Max_row=Max_row*Num_choices(Category_num)
2836  NEXT Category_num
2837  Max_row=MIN(Max_row,16)+1     !+1 for "All" line
2838  REDIM Box$(1:Max_col,1:Max_row)
2839    !
2840    !define constants for other columns
2841  Active_col=2
2842  Ch_name_col=3
2843  Type_col=4
2844  Y_min_col=3+Num_categories
2845  Y_max_col=4+Num_categories
2846  Xstart_col=5+Num_categories
2847    !
2848    !re-DIM arrays in common so they can be indexed by column instead
2849    !of category_num
2850  REDIM Num_choices(3:2+Num_categories)
2851  REDIM Choices$(3:2+Num_categories,1:MAX(Num_choices(*)))
2852 !
2853 ! These data statements define the setup and titles for each column
2854 !
2855 !   col_width  title1         title2      Prompt
2856 !   ---------  ----------     ----------  --------------------
2857  DATA    5,     "Trace",      "Num",      ""
2858  DATA    4,     "Act-",       "ive",      "Trace active: (Yes or No)"
2859  !externally defined columns show up here
2860  DATA   12,     "Trace",      "Name",     "Enter name of input to plot"
2861  DATA    6,     "Trace",      "Type",     "Enter type of plot (TIME)"
2862  DATA    9,     "Y Axis",     "Min",      "Y Axis minimum: (value or ""Default"")"
2863  DATA    9,     "Y Axis",     "Max",      "Y Axis maximum: (value or ""Default"")"
2864  DATA    9,     "Plot Blk",     "Start",  "Start of plot block relative to through-put start (mSec or ""Default"")"
2865 !
2866 !
2867 !read spread sheet setup into arrays
2868  Title$(1,0)="DISPLAY SETUP"
2869  FOR C=1 TO Max_col
2870    READ Col_width(C),Title$(C,1),Title$(C,2),Prompt$(C)
2871  NEXT C
2872    !
2873 SUBEND
2874  ! PAGE -> 
2875  !************************************************************************
2876 Post_spread:SUB Post_spread(Modified)
2877  !This is the display spread sheet.  It will probably be called when the
2878  !DISPLAY SETUP softkey is pressed.  For up to 9 traces, it allows the
2879  !user to make the trace active, change Y axis scaling, or change
2880  !other items.
2881  !
2882  COM /Post_spread1/ Box$(*),Row,Col,Start_row
2883  COM /Post_spread2/ Title$(*),Prompt$(*),Col_width(*)
2884  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
2885  COM /Post_spread4/ Choices$(*),Num_choices(*)
2886 !
2887  DIM New_entry$[160]
2888  Modify_col=2    !col 2 and up will be modifiable
2889  Max_row=SIZE(Box$,2)
2890 !
2891  GOSUB Label_keys
2892  CALL User_clr_scr
2893 !Now call spread sheet.  It returns with New_entry$ and Row and Col
2894  Done=0
2895  Modified=0
2896  REPEAT
2897    CALL User_spread(Box$(*),Title$(*),Prompt$(*),New_entry$,Col_width(*),Modify_col,Col,Row,Start_row)
2898    SELECT FNUser_check_key
2899    CASE 0     !no key pressed, must be a New_entry$ for Box
2900      GOSUB New_entry
2901    CASE 5           !the Reset key
2902      Dummy=FNUser_get_key
2903      CALL Post_reset
2904      Modified=1
2905    CASE 6           !"Color" softkey
2906      Dummy=FNUser_get_key
2907      IF FNPlot_have_color THEN 
2908        CALL Plot_set_color(NOT FNPlot_use_color)
2909        GOSUB Label_keys
2910      ELSE
2911        BEEP 651,.03
2912      END IF
2913    CASE 7           !Prev
2914      Dummy=FNUser_get_key
2915      GOSUB Prev_choice
2916    CASE 8           !next
2917      Dummy=FNUser_get_key
2918      GOSUB Next_choice
2919    CASE ELSE        !a softkey but not one of mine, so exit
2920      Done=1
2921    END SELECT
2922  UNTIL Done
2923  CALL User_clr_scr
2924  IF Modified THEN CALL Post_update_com
2925  SUBEXIT
2926 New_entry:         !------------------------------------------------
2927   !acts on new_entry from spread_sheet
2928  New_entry$=UPC$(TRIM$(New_entry$))
2929  IF New_entry$[1,1]="""" THEN New_entry$=TRIM$(New_entry$[2])   !delete "
2930  IF New_entry$<>"" THEN 
2931    Modified=1
2932    SELECT Col
2933    CASE Active_col
2934      SELECT New_entry$[1,1]
2935      CASE "Y","*"
2936        IF Row=1 THEN    !all
2937          FOR R=2 TO Max_row
2938            Box$(Col,R)="*"
2939          NEXT R
2940        ELSE
2941          Box$(Col,Row)="*"
2942        END IF
2943      CASE "N"
2944        IF Row=1 THEN 
2945          FOR R=2 TO Max_row
2946            Box$(Col,R)=""
2947          NEXT R
2948        ELSE
2949          Box$(Col,Row)=""
2950        END IF
2951      CASE ELSE
2952        BEEP 200,.1
2953      END SELECT
2954    CASE Active_col+1 TO Y_min_col-1    !application dependent cols
2955      CALL Lib_match2(New_entry$,Choices$(*),Col,Found,Choice_num)
2956      IF Found THEN 
2957        IF Row=1 THEN 
2958          FOR R=2 TO Max_row
2959            Box$(Col,R)=Choices$(Col,Choice_num)
2960          NEXT R
2961        ELSE
2962          Box$(Col,Row)=Choices$(Col,Choice_num)
2963        END IF
2964      ELSE
2965        BEEP 200,.1
2966      END IF
2967    CASE Y_min_col,Y_max_col,Xstart_col
2968      IF New_entry$[1,1]="D" THEN 
2969        IF Row=1 THEN 
2970          FOR R=2 TO Max_row
2971            Box$(Col,R)="Default"
2972          NEXT R
2973        ELSE
2974          Box$(Col,Row)="Default"
2975        END IF
2976      ELSE
2977        ON ERROR GOTO Not_a_number
2978        Dummy=VAL(New_entry$)
2979        IF Row=1 THEN 
2980          FOR R=2 TO Max_row
2981            IF Col=Xstart_col THEN 
2982              Post_new_startx(R-1,Dummy)
2983            ELSE
2984              Box$(Col,R)=New_entry$
2985            END IF
2986          NEXT R
2987        ELSE
2988          IF Col=Xstart_col THEN 
2989            Post_new_startx(Row-1,Dummy)
2990          ELSE
2991            Box$(Col,Row)=New_entry$
2992          END IF
2993        END IF
2994        OFF ERROR 
2995        GOTO Ok
2996 Not_a_number:OFF ERROR 
2997        DISP ERRM$
2998        BEEP 200,.1
2999        WAIT 2
3000        DISP 
3001 Ok:        !
3002      END IF
3003    END SELECT
3004  END IF
3005  RETURN 
3006 Prev_choice:  !--------------------------------------------------
3007  SELECT Col
3008  CASE Active_col
3009    Modified=1
3010    GOSUB Toggle
3011  CASE Active_col+1 TO Y_min_col-1    !application dependent columns
3012    IF Num_choices(Col)>1 THEN 
3013      Modified=1
3014        !find the choice_num of the current selection and decrement
3015      IF Row=1 THEN    !first row is "all"
3016        CALL Lib_match2(Box$(Col,2),Choices$(*),Col,Found,Choice_num)
3017      ELSE
3018        CALL Lib_match2(Box$(Col,Row),Choices$(*),Col,Found,Choice_num)
3019      END IF
3020      Choice_num=Choice_num-1
3021      IF Choice_num<1 THEN Choice_num=Num_choices(Col)
3022      IF Row=1 THEN 
3023        FOR R=2 TO Max_row
3024          Box$(Col,R)=Choices$(Col,Choice_num)
3025        NEXT R
3026      ELSE
3027        Box$(Col,Row)=Choices$(Col,Choice_num)
3028      END IF
3029    ELSE
3030      BEEP 651,.03
3031    END IF
3032  CASE ELSE                  !other column
3033    BEEP 651,.03
3034  END SELECT
3035  RETURN 
3036 Next_choice:   !-------------------------------------------------
3037  SELECT Col
3038  CASE Active_col
3039    Modified=1
3040    GOSUB Toggle
3041  CASE Active_col+1 TO Y_min_col-1    !application dependent columns
3042    IF Num_choices(Col)>1 THEN 
3043      Modified=1
3044        !find the choice_num of the current selection and increment
3045      IF Row=1 THEN    !first row is "all"
3046        CALL Lib_match2(Box$(Col,2),Choices$(*),Col,Found,Choice_num)
3047      ELSE
3048        CALL Lib_match2(Box$(Col,Row),Choices$(*),Col,Found,Choice_num)
3049      END IF
3050      Choice_num=Choice_num+1
3051      IF Choice_num>Num_choices(Col) THEN Choice_num=1
3052      IF Row=1 THEN       !ALL rows
3053        FOR R=2 TO Max_row
3054          Box$(Col,R)=Choices$(Col,Choice_num)
3055        NEXT R
3056      ELSE
3057        Box$(Col,Row)=Choices$(Col,Choice_num)
3058      END IF
3059    ELSE
3060      BEEP 651,.03
3061    END IF
3062  CASE ELSE                  !other column
3063    BEEP 651,.03
3064  END SELECT
3065  RETURN 
3066 Toggle:       !--------------------------------------------------
3067  IF Row=1 THEN           !ALL rows
3068    IF Box$(Col,2)="*" THEN 
3069      FOR R=2 TO Max_row
3070        Box$(Col,R)=""
3071      NEXT R
3072    ELSE
3073      FOR R=2 TO Max_row
3074        Box$(Col,R)="*"
3075      NEXT R
3076    END IF
3077  ELSE
3078    IF Box$(Col,Row)="*" THEN 
3079      Box$(Col,Row)=""
3080    ELSE
3081      Box$(Col,Row)="*"
3082    END IF
3083  END IF
3084  RETURN 
3085 Label_keys:    !------------------------------------------------------
3086 ! Overwrite unused softkeys
3087  ON KEY 5 LABEL FNUser_keylabel$("Reset") CALL User_key5isr
3088  IF FNPlot_have_color THEN 
3089    IF FNPlot_use_color THEN 
3090      ON KEY 6 LABEL FNUser_keylabel$("Color *") CALL User_key6isr
3091    ELSE
3092      ON KEY 6 LABEL FNUser_keylabel$("Color") CALL User_key6isr
3093    END IF
3094  ELSE
3095    ON KEY 6 LABEL "" CALL User_key6isr
3096  END IF
3097  ON KEY 7 LABEL FNUser_keylabel$("Previous") CALL User_key7isr
3098  ON KEY 8 LABEL FNUser_keylabel$("Next") CALL User_key8isr
3099  RETURN 
3100 SUBEND
3101  ! PAGE -> 
3102  !************************************************************************
3103 Post_update_com:SUB Post_update_com
3104  !called after the display spread sheet has changed to translate
3105  !from spreadsheet to plot form.  It takes stuff from the Box$ array
3106  !(the spreadsheet) and generates the number of plots, min and max y values
3107  !and plot titles.
3108  !
3109  COM /Post_spread1/ Box$(*),Row,Col,Start_row
3110  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
3111  COM /Post_spread4/ Choices$(*),Num_choices(*)
3112  COM /Post_choice/ Plot_choice(*)
3113  ALLOCATE Plot_titles$(1:9)[45],Y_max$(1:9)[10],Y_min$(1:9)[10]
3114  DIM Title$[255],Temp$[40]
3115    !copy Box$ info into  arrays for passing to Disp_put_traces
3116  Max_row=SIZE(Box$,2)
3117  Plot_num=0
3118  FOR R=2 TO Max_row             !for each row, check for active plot
3119    IF Box$(Active_col,R)="*" THEN 
3120      GOSUB Do_the_row
3121    END IF
3122  NEXT R
3123  IF Plot_num<1 THEN 
3124    R=2
3125    Box$(Active_col,R)="*"      !make first one active
3126    GOSUB Do_the_row
3127    CALL User_error("You must have at least one active trace")
3128  END IF
3129  CALL Disp_put_traces(Plot_num,0,Y_max$(*),Y_min$(*))
3130  CALL Disp_put_titles(Plot_titles$(*))
3131  SUBEXIT
3132 Do_the_row:  !-------------------------------------------------------
3133    !processes row R  of the spread sheet data
3134  IF Plot_num<9 THEN 
3135    Plot_num=Plot_num+1
3136    REDIM Plot_titles$(1:Plot_num),Y_max$(1:Plot_num),Y_min$(1:Plot_num)
3137      !
3138      !built title out of application dep cols
3139    Title$=""
3140    FOR C=Active_col+1 TO Y_min_col-1
3141      Title$=Title$&Box$(C,R)&" "
3142    NEXT C
3143    IF LEN(Title$)<45 THEN 
3144      Plot_titles$(Plot_num)=Title$
3145    ELSE
3146      Plot_titles$(Plot_num)=Title$[1,45]
3147    END IF
3148      !
3149      !check for swapped min/max
3150    IF Box$(Y_min_col,R)<>"Default" AND Box$(Y_max_col,R)<>"Default" THEN 
3151      IF VAL(Box$(Y_min_col,R))>VAL(Box$(Y_max_col,R)) THEN       !min>max ?
3152        Temp$=Box$(Y_min_col,R)
3153        Box$(Y_min_col,R)=Box$(Y_max_col,R)
3154        Box$(Y_max_col,R)=Temp$
3155      END IF
3156    END IF
3157    Y_min$(Plot_num)=Box$(Y_min_col,R)
3158    Y_max$(Plot_num)=Box$(Y_max_col,R)
3159      !
3160      !encode application dependent stuff
3161    FOR C=Active_col+1 TO Y_min_col-1    !for each appl dependent col
3162      CALL Lib_match2(Box$(C,R),Choices$(*),C,Found,Choice_num)
3163      IF Found THEN 
3164        Plot_choice(Plot_num,C-Active_col)=Choice_num
3165      ELSE
3166        CALL User_stop("match failed")
3167      END IF
3168    NEXT C
3169  END IF       !plots<=9
3170  RETURN 
3171 SUBEND
3172  ! PAGE -> 
3173  !************************************************************************
3174 Post_reset:SUB Post_reset
3175  !Resets the display spread sheet to its initial state.
3176  !Called by Post_spread_set.
3177  !The initial state defines up to 16 plots unique plots using all
3178  !combinations of Choices$() for each application dependent column.
3179  !Y axis scaling is set to "Default", and several plots are set active.
3180  !
3181  COM /Post_spread1/ Box$(*),Row,Col,Start_row
3182  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
3183  COM /Post_spread4/ Choices$(*),Num_choices(*)
3184  INTEGER A(0:5)
3185  GESCAPE CRT,3;A(*)     !get CRT pixel size in A(*)
3186  IF A(2)>1000 THEN      !if CRT is high resolution then
3187    Max_active=9         !display up to 9 traces as default
3188  ELSE
3189    Max_active=4
3190  END IF
3191  !
3192  MAT Box$= ("")
3193  Max_row=SIZE(Box$,2)
3194    !
3195    !set up "All" row
3196  Box$(1,1)="All"
3197  ALLOCATE Current_choice(3:3+Num_categories)
3198    !Current_choice has an element for each column (category) to be varied.
3199    !The values are the choice numbers and are incremented in a ripple
3200    !counter like fashion.
3201  MAT Current_choice= (1)    !first row is first choice for all categories.
3202  FOR R=2 TO Max_row
3203    Box$(1,R)=VAL$(R-1)
3204    IF (R-1)<=Max_active THEN Box$(Active_col,R)="*"
3205    FOR C=3 TO 2+Num_categories
3206      Box$(C,R)=Choices$(C,Current_choice(C))
3207    NEXT C
3208    Box$(Y_min_col,R)="Default"
3209    Box$(Y_max_col,R)="Default"
3210    Box$(Xstart_col,R)="Default"
3211      !increment current_choice array
3212    Current_choice(3)=Current_choice(3)+1    !increment choice in left most col
3213    FOR C=3 TO 2+Num_categories              !check each col for wrap
3214      IF Current_choice(C)>Num_choices(C) THEN   !need to "carry"
3215        Current_choice(C)=1
3216        Current_choice(C+1)=Current_choice(C+1)+1
3217      END IF
3218    NEXT C
3219  NEXT R
3220 SUBEND
3221  ! PAGE -> 
3222  !************************************************************************
3223 Post_inpt_num:DEF FNPost_inpt_num(Plot_num)
3224  !Query function used to get current selection from "Channel Name"
3225  !column
3226  ! Returns an index into the Tr_name$(*) array that was passed to
3227  ! Post_spread_set.
3228  RETURN Plot_choice(Plot_num,Ch_name_col-Active_col)
3229  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
3230  COM /Post_choice/ Plot_choice(*)
3231 FNEND
3232  ! PAGE -> 
3233  !************************************************************************
3234 Post_tr_type:DEF FNPost_tr_type(Plot_num)
3235  !Query function used to get current selection from "Trace Type"
3236  !column
3237  ! Returns an index into the Tr_Type$(*) array that was passed to
3238  ! Post_spread_set.
3239  RETURN Plot_choice(Plot_num,Type_col-Active_col)
3240  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
3241  COM /Post_choice/ Plot_choice(*)
3242 FNEND
3243  ! PAGE -> 
3244  !************************************************************************
3245 Post_start_x:DEF FNPost_start_x(Plot_num)
3246  !Query function used to get current selection from "Plot blk start"
3247  !column
3248  ! Returns the value in Box$ for the plot_num'th active plot.
3249  COM /Post_spread1/ Box$(*),Row,Col,Start_row
3250  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
3251  COM /Post_choice/ Plot_choice(*)
3252  Row_num=1
3253  Found=0
3254  Cntr=0
3255  Max_row=SIZE(Box$,2)
3256  REPEAT
3257    Row_num=Row_num+1
3258    IF Box$(Active_col,Row_num)="*" THEN 
3259      Cntr=Cntr+1
3260      IF Cntr=Plot_num THEN Found=1
3261    END IF
3262  UNTIL Found=1 OR Row_num=Max_row
3263  IF UPC$(Box$(Xstart_col,Row_num))="DEFAULT" THEN 
3264    RETURN 0
3265  ELSE
3266    RETURN VAL(Box$(Xstart_col,Row_num))
3267  END IF
3268 FNEND
3269  ! PAGE -> 
3270  !************************************************************************
3271 Post_new_startx:SUB Post_new_startx(Plot_num,Start_x)
3272  !
3273  ! Updates an element of "Plot Start" column with a new number (in mSec.)
3274  ! Rounds Start_x to a multiple of plot block sizes from the
3275  ! start of the through-put.  Plot_num refers to the nth active plot.
3276  !
3277  COM /Post_spread1/ Box$(*),Row,Col,Start_row
3278  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
3279  COM /Post_choice/ Plot_choice(*)
3280    !
3281  IF Plot_num>FNDisp_num_plots THEN CALL User_stop("Plot_num too high in Post_new_startx")
3282  Samp_rate=FNThru_sess_parm("SPAN")*2.56E-3
3283  Block_size=FNThru_disc_parm("BLOCKSIZE")
3284  Loops=FNThru_disc_parm("ACTUAL SCANS")
3285  Tot_blocks=FNThru_disc_parm("SCANS")   !NUM OF PLOT BLOCKS.
3286  Xfer_size=FNThru_disc_parm("XFER SIZE")
3287  IF FNThru_sess_parm("ZOOM")=1 THEN Samp_rate=Samp_rate*2.
3288  Num_blks=INT(((Samp_rate*Start_x)/Block_size)+.5)
3289  Start_x=MAX(Block_size*Num_blks/Samp_rate,0)
3290  Start_x=MIN(Start_x,((Loops*Xfer_size-Block_size)/Samp_rate))
3291  Start_x=MAX(0,Start_x)
3292    ! find the 'Plot_num'th active plot.
3293  Row_num=1
3294  Found=0
3295  Cntr=0
3296  REPEAT
3297    Row_num=Row_num+1
3298    IF Box$(Active_col,Row_num)="*" THEN 
3299      Cntr=Cntr+1
3300      IF Cntr=Plot_num THEN Found=1
3301    END IF
3302  UNTIL Found=1
3303  Box$(Xstart_col,Row_num)=VAL$(Start_x)
3304 SUBEND
3305  ! PAGE -> 
3306  !************************************************************************
3307 Meas_do_cat:SUB Meas_do_cat
3308  !
3309  ! Does a catalog of the thruput disc, and stores the names of all
3310  ! usable BDAT files in a common block.  A usable file is defined as:
3311  !      1. Must be a BDAT file
3312  !      2  Must have 256 byte records
3313  !      3. Must have at least 296 records. The first 295 records are used
3314  !         for session, setup, cal and other info, subsequent records are
3315  !         used for actual data, 2 bytes per sample.
3316  !
3317  ! Note that in order to get address data from the BASIC CAT instruction,
3318  ! this subprogram uses a RAM volume (#14) as a "PRINTER IS" device to
3319  ! store the catalog, and then reads the information out of the RAM volume.
3320  !
3321  COM /Meas_file_info/ File_name$(*),File_length(*),Rec_size(*),Start_addr(*),Num_files
3322  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
3323  COM /Meas_sprd/ Box$(1:2,1:15)[40],Title$(1:2,0:2)[40],Prompt$(1:15)[80]
3324  DIM Media$[20]
3325  ALLOCATE Cat_line$[47]
3326 !
3327 ! HEAD STANDS TO GET FILE START ADDRESS FROM BASIC:
3328  Num_files=0
3329  MAT File_name$= ("")
3330  DISP "Reading catalog of disc"
3331  INITIALIZE ":MEMORY,0,14",68
3332  CREATE BDAT "CATINFO:MEMORY,0,14",64
3333  Old_printer$=SYSTEM$("PRINTER IS")
3334  PRINTER IS "CATINFO:MEMORY,0,14"
3335    !
3336  Disc_addr=FNMeas_thru_parm("DISC ADDRESS")+(FNHw_cur_dev_sel DIV 100)*100
3337  Unit_num=FNMeas_thru_parm("DISC UNIT")
3338  Vol_num=FNMeas_thru_parm("DISC VOL")
3339  Media$=":CS80,"&VAL$(Disc_addr)&","&VAL$(Unit_num)&","&VAL$(Vol_num)
3340  ON ERROR GOTO No_disc
3341  CAT Media$;NO HEADER,COUNT Tot_files
3342  OFF ERROR 
3343  ON ERROR GOSUB Restore2   !IN CASE ITS NOT A NUMBER.
3344  PRINTER IS VAL(Old_printer$)
3345  OFF ERROR 
3346 !
3347 ! NOW PARSE OUT THE RESULTS OF THE CAT.
3348  ASSIGN @Catstuff TO "CATINFO:MEMORY,0,14";FORMAT ON
3349  FOR I=1 TO Tot_files
3350    ENTER @Catstuff;Cat_line$
3351    IF Cat_line$[15,18]="BDAT" AND TRIM$(Cat_line$[29,37])="256" AND VAL(Cat_line$[20,28])>295 THEN   !ITS AN OK FILE.
3352      Num_files=Num_files+1
3353      File_name$(Num_files)=Cat_line$[1,10]
3354      File_length(Num_files)=VAL(Cat_line$[20,28])
3355      Rec_size(Num_files)=VAL(Cat_line$[29,37])
3356      Start_addr(Num_files)=VAL(Cat_line$[38,47])
3357    END IF
3358  NEXT I
3359  ASSIGN @Catstuff TO *
3360  DISP 
3361  IF Num_files=0 THEN CALL User_error("NO BDAT FILES FOUND OR FILES TOO SMALL ON "&Media$)
3362  INITIALIZE ":MEMORY,0,14",0
3363  SUBEXIT
3364 Restore2: ! COME HERE IF THE PRINTER WAS A PATH NAME.
3365  PRINTER IS Old_printer$
3366  RETURN 
3367 No_disc:  ! come here if no disc at this address.
3368  BEEP 
3369  User_error("NO DISC PRESENT AT "&Media$)
3370  ON ERROR GOSUB Restore2   !IN CASE ITS NOT A NUMBER.
3371  PRINTER IS VAL(Old_printer$)
3372  OFF ERROR 
3373  ASSIGN @Catstuff TO *
3374  DISP 
3375  INITIALIZE ":MEMORY,0,14",0
3376 SUBEND
3377  ! PAGE -> 
3378  !************************************************************************
3379 Meas_init_file:SUB Meas_init_file
3380  !
3381  ! Called at power-up, or when the disc drive is changed (HP-IB addr,
3382  ! unit,or volume number), after Meas_do_cat.  It picks the first usable
3383  ! BDAT file on the disc for a thruput file.
3384  !
3385  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
3386  COM /Meas_file_info/ File_name$(*),File_length(*),Rec_size(*),Start_addr(*),Num_files
3387  COM /Meas_sprd/ Box$(1:2,1:15)[40],Title$(1:2,0:2)[40],Prompt$(1:15)[80]
3388  ! IF Num_files=0 THEN    !before Rev 1.1
3389  IF 1 THEN                !Rev 1.1 change to avoid overwriting files (CKS)
3390    Box$(2,File_r)=""
3391    Num_files=0
3392  ELSE
3393    Box$(2,File_r)=TRIM$(File_name$(1))
3394  END IF
3395 SUBEND
3396  ! PAGE -> 
3397  !************************************************************************
3398 Meas_file_spec:DEF FNMeas_file_spec$
3399  !
3400  ! Returns file specification of current through-put file in the form:
3401  ! "<filename>:CS80,<sel_code*100+hp-ib_addr>,<unit_num>,<vol_num>"
3402  !
3403  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
3404  COM /Meas_file_info/ File_name$(*),File_length(*),Rec_size(*),Start_addr(*),Num_files
3405  COM /Meas_sprd/ Box$(1:2,1:15)[40],Title$(1:2,0:2)[40],Prompt$(1:15)[80]
3406    !
3407  IF Num_files>0 THEN 
3408    RETURN TRIM$(Box$(2,File_r))&":CS80,"&VAL$((FNHw_cur_dev_sel DIV 100)*100+VAL(Box$(2,Hp_ib_r)))&","&Box$(2,Unit_r)&","&Box$(2,Vol_r)
3409  ELSE
3410    RETURN ""
3411  END IF
3412 FNEND
3413  ! PAGE -> 
3414  !************************************************************************
3415 Post_next_rec:SUB Post_next_rec(Mod_all_plots,Disp_modified)
3416  !
3417  ! Changes the POST parms to increment the first record number to be read
3418  ! from the disc, for all the plots or just the first one.
3419  ! Checks for the last record of a thruput.
3420  !
3421  ! INPUTS:  Mod_all_plots:  1=increment all the plots
3422  !
3423  ! OUTPUTS: Disp_modified:  1=plot parms actually changed.
3424  !
3425  Disp_modified=0
3426  Loops=FNThru_disc_parm("ACTUAL SCANS")
3427  Xfer_size=FNThru_disc_parm("XFER SIZE")
3428  Block_size=FNThru_disc_parm("BLOCKSIZE")
3429 !  Valid_blks=Loops*Block_size/Xfer_size
3430  Tot_blocks=FNThru_disc_parm("SCANS")    !PLOT BLOCKS
3431  Span=FNThru_sess_parm("SPAN")
3432  Samp_rate=2.56E-3*Span      !SAMP/mSEC
3433  IF FNThru_sess_parm("ZOOM")=1 THEN Samp_rate=Samp_rate*2.
3434    !
3435  IF Mod_all_plots THEN 
3436    Num_mods=FNDisp_num_plots
3437    FOR M=1 TO Num_mods
3438      Start_time=FNPost_start_x(M)
3439      Start_blk=Start_time*Samp_rate
3440      IF Start_blk+Block_size<>Loops*Xfer_size THEN 
3441        Start_time=Start_time+(Block_size/Samp_rate)
3442        Post_new_startx(M,Start_time)
3443        Disp_modified=1
3444      END IF
3445    NEXT M
3446  ELSE    !JUST ONE PLOT (the first one)
3447 !
3448    Plot_num=1
3449 !
3450 Increment: !
3451    Start_time=FNPost_start_x(Plot_num)
3452    Start_blk=Start_time*Samp_rate    !SAMPLE WE CURRENTLY START AT.
3453      ! IS THERE ANOTHER BLOCK AVAILABLE?
3454    IF Start_blk+Block_size<>Loops*Xfer_size THEN 
3455      Start_time=Start_time+(Block_size/Samp_rate)
3456      Post_new_startx(Plot_num,Start_time)
3457      Disp_modified=1
3458    END IF
3459  END IF
3460  IF Disp_modified=0 THEN CALL User_error("ALREADY AT END OF DISC DATA")
3461 SUBEND
3462  ! PAGE -> 
3463  !-----------------------------------------------------------------------
3464 Post_prev_rec:SUB Post_prev_rec(Mod_all_plots,Disp_modified)
3465  !
3466    ! Changes the post_parms so that the previous block will be read
3467    !from the disc, for all the plots or just the first one.
3468    !
3469  Disp_modified=0
3470  Xfer_size=FNThru_disc_parm("XFER SIZE")
3471  Block_size=FNThru_disc_parm("BLOCKSIZE")
3472  Span=FNThru_sess_parm("SPAN")
3473  Samp_rate=2.56E-3*Span      !SAMP/mSEC
3474  Zoom=FNThru_sess_parm("ZOOM")
3475  IF Zoom=1 THEN Samp_rate=Samp_rate*2.
3476  IF Mod_all_plots THEN 
3477    Num_mods=FNDisp_num_plots
3478    FOR M=1 TO Num_mods
3479      Start_time=FNPost_start_x(M)   !START OF PLOT DATA IN mSEC.
3480      Start_blk=INT(Start_time*Samp_rate/Block_size)+1   !CURRENT SCAN.
3481      IF Start_blk>1 THEN 
3482        Start_time=Start_time-(Block_size/Samp_rate)
3483        Post_new_startx(M,Start_time)
3484        Disp_modified=1
3485      END IF
3486    NEXT M
3487  ELSE    !JUST THE FIRST PLOT
3488 Prompt:  !
3489    Plot_num=1
3490 Decrement: !
3491    Start_time=FNPost_start_x(Plot_num)     !START OF PLOT DATA IN mSEC.
3492    Start_blk=INT(Start_time*Samp_rate/Block_size)+1     !CURRENT SCAN.
3493    IF Start_blk>1 THEN 
3494      Start_time=Start_time-(Block_size/Samp_rate)
3495      Post_new_startx(Plot_num,Start_time)
3496      Disp_modified=1
3497    END IF
3498    Disp_modified=1
3499  END IF
3500  IF Disp_modified=0 THEN CALL User_error("ALREADY AT START OF DATA")
3501 SUBEND
3502  ! PAGE -> 
3503  !-----------------------------------------------------------------------
3504 Post_choice:DEF FNPost_choice(Plot_num,Category_num)
3505  !This function returns the current selection of an application
3506  !dependent column of the display spread sheet.  It returns an index
3507  !into the array Choices$(*), given the plot number and category number.
3508  COM /Post_choice/ Plot_choice(*)
3509  RETURN Plot_choice(Plot_num,Category_num)
3510 FNEND
3511  !************************************************************************
3512 Thru_wait_cntr:SUB Thru_wait_cntr(Timeout_time,Aborted)
3513!
3514!      This  subprogram is used to hold off execution of the host program
3515 !      until the host becomes the active HP-IB bus controller.  This sub
3516 !      replaces Hw_wait_cntrlr to solve a problem.  The problem is that
3517 !      if the Icode program errors and dies, control is not returned to
3518 !      the host and the host has no way to know that there is a problem.
3519 !      This sub monitors the HP-IB bus, and if there is no activity for
3520 !      Timeout_time seconds, it does an ABORT to regain control and
3521 !      return Aborted=1.
3522  !
3523  INTEGER Status6,Sel_code,Hpib_addr
3524  REAL Start_time,Last_activity,Status7
3525  Sel_code=FNHw_cur_dev_sel DIV 100
3526  Hpib_addr=FNHw_cur_dev_sel MOD 100
3527  Aborted=0
3528  Start_time=TIMEDATE
3529  REPEAT
3530    STATUS Sel_code,6;Status6
3531    STATUS Sel_code,7;Status7
3532    IF BIT(Status6,6) THEN SUBEXIT       !Control was passed back.
3533    IF Last_activity<>Status6+Status7 THEN 
3534          !The sum of the status register is used to gage HP-IB
3535          !activity.  If they are changing then things are ok,
3536          !and the timeout timer can be reset.
3537      Start_time=TIMEDATE
3538      Last_activity=Status6+Status7
3539    END IF
3540  UNTIL ABS(TIMEDATE-Start_time)>Timeout_time OR FNUser_key_press
3541      !
3542      !The only way to get here is to have a timeout occur or key press
3543  IF FNUser_key_press THEN 
3544    CALL User_error("Through-put aborted.")
3545  ELSE
3546    CALL User_error("Timeout error during through-put or disc read.")
3547  END IF
3548  ABORT Sel_code      !to get bus control  (CLEAR won't work)
3549  WAIT .1
3550  CLEAR Sel_code
3551  CLEAR Sel_code*100+Hpib_addr
3552  Aborted=1
3553 SUBEND
3554  !
3555  !**********************************************************************
3556 Meas_load:SUB Meas_load(@File,Ok)
3557  ! This subprogram loads the measurement setups from file @File,
3558  ! and returns Ok=1 if the load is successful. It then writes the
3559  ! measurement setups states to the hardware.
3560  !
3561  COM /Meas_sprd/ Box$(*),Title$(*),Prompt$(*)
3562  COM /Meas_cmnd/ Cmnd$(*),Def_value$(*)
3563  COM /Meas_rows/ Cmnd_header,Info_start,Bsiz_r,Tdly_r,Cmode_r,Hp_ib_r,Unit_r,Vol_r,File_r,Tmode_r,Len_r,Loops_r,Span_r,Zoom_r,Cfreq_r,Row
3564  !
3565  Ok=1
3566  !
3567  INTEGER File_format_rev
3568  !
3569  ENTER @File;File_format_rev
3570  SELECT File_format_rev
3571  CASE 2620
3572    File_load_s(@File,Box$(*))
3573  CASE ELSE
3574    User_error("ERROR Incompatible display file format in Meas_load.")
3575    Ok=0
3576    SUBEXIT
3577  END SELECT
3578  ! write measurement spread sheet commands
3579  FOR Row=Cmnd_header+1 TO Info_start-1
3580    IF Cmnd$(Row)="TRANSFER SIZE" THEN  ! set TBLK and BSIZ the same
3581      Tmp$="BLOCK SIZE"
3582      Inpt_cmd("ALL INPUT",Tmp$,Box$(2,Row))
3583      Tmp$=Cmnd$(Row)
3584      Inpt_cmd("ALL INPUT",Tmp$,Box$(2,Row))
3585    ELSE
3586      Inpt_cmd("ALL INPUT",Cmnd$(Row),Box$(2,Row))
3587    END IF
3588  NEXT Row
3589  Row=2  ! initialize cursor row
3590 SUBEND
3591  !*********************************************************************
3592 Meas_save:SUB Meas_save(@File,Ok)
3593   ! This subprogram saves the current measurement setups (Box$(*))
3594   ! in the file specified by @File, and returns Ok=1 if it successfully
3595   ! saves the setups.
3596   !
3597  COM /Meas_sprd/ Box$(*),Title$(*),Prompt$(*)
3598   !
3599  INTEGER File_format_rev
3600  File_format_rev=2620
3601  OUTPUT @File;File_format_rev
3602  File_save_s(@File,Box$(*))
3603  Ok=1
3604 SUBEND
3605   !*********************************************************************
3606 User_disp_save:SUB User_disp_save(@File,Ok)
3607   ! This subprogram saves the state of the display spread sheet
3608   ! into the file referenced by @File, and returns Ok=1 if successful.
3609   !
3610  COM /Post_spread1/ Box$(*),Row,Col,Start_row
3611   !
3612  INTEGER File_format_rev
3613  File_format_rev=2621
3614  OUTPUT @File;File_format_rev
3615   !
3616  CALL File_save_s(@File,Box$(*))
3617  Ok=1
3618 SUBEND
3619   !***********************************************************************
3620 User_disp_load:SUB User_disp_load(@File,Ok)
3621   ! This subprogram loads the state of the display spread sheet
3622   ! from file @File and returns Ok=1 if successful. It then calls
3623   ! Post_update_com to update the display plot COMMON.
3624   !
3625  COM /Post_spread1/ Box$(*),Row,Col,Start_row
3626  COM /Post_spread3/ Active_col,Ch_name_col,Type_col,Y_max_col,Y_min_col,Num_categories,Xstart_col
3627   !
3628  INTEGER File_format_rev
3629  ENTER @File;File_format_rev
3630  SELECT File_format_rev
3631  CASE 2621
3632    CALL File_load_s(@File,Box$(*))
3633  CASE ELSE   ! unknown rev
3634    CALL User_error("ERROR Incompatible display file format in User_disp_load.")
3635    Ok=0
3636    SUBEXIT
3637  END SELECT
3638   !
3639  CALL Post_update_com
3640  Ok=1
3641 SUBEND
3642   !********************************************************************
3643 Cs80_describe:SUB Cs80_describe(Num_heads,Num_sectors,Bytes_per_block)
3644   ! This module executes a CS80 DESCRIBE command. This command interrogates
3645   ! the disk for device dependent disk parameters.
3646   !
3647  DIM Disc$[500]
3648   !
3649  Hpib=FNHw_cur_dev_sel DIV 100
3650  Disc_addr=FNMeas_thru_parm("DISC ADDRESS")
3651  Disc_unit=FNMeas_thru_parm("DISC UNIT")
3652  Disc_vol=FNMeas_thru_parm("DISC VOLUME")
3653   !
3654  Set_unit=32+Disc_unit
3655  Set_vol=64+Disc_vol
3656   !
3657  CLEAR Hpib
3658   ! ******* send command message
3659  SEND Hpib;MTA UNL LISTEN Disc_addr SEC 101 DATA Set_unit,Set_vol,16,0,0,0,0,0,0,24,0,0,0,256,53 END UNL 
3660  REPEAT
3661  UNTIL BIT(PPOLL(Hpib),7-Disc_addr)
3662   !******** receive execution message
3663  SEND Hpib;MLA TALK Disc_addr SEC 110
3664  ENTER Hpib USING "-K";Disc$
3665  SEND Hpib;UNT 
3666  REPEAT
3667  UNTIL BIT(PPOLL(Hpib),7-Disc_addr)
3668   !******** read status from reporting message
3669  SEND Hpib;MLA TALK Disc_addr SEC 112
3670  ENTER Hpib USING "-K";Status$
3671  SEND Hpib;UNT UNL 
3672   ! if read OK, then decode data
3673  IF Status$=CHR$(0) THEN 
3674    Num_heads=NUM(Disc$[28,28])+1
3675    Num_sectors=NUM(Disc$[29,29])*256+NUM(Disc$[30,30])+1
3676    Bytes_per_block=NUM(Disc$[10,10])*256+NUM(Disc$[11,11])
3677  ELSE
3678    Num_heads=0
3679    Num_sectors=0
3680    Bytes_per_block=0
3681  END IF
3682 SUBEND