c                
c   Copyright (c) 1990 by Dwight Meglan
c
      subroutine ShowStatus( CMND )
      implicit none

      include 'tel_cons.inc'
      include 'tel_strc.inc'
      include 'tel_file.inc'
      include 'tel_grph.inc'
      include 'tel_chrt.inc'
      include 'tel_3dvu.inc'
      include 'tel_name.inc'

      record /CmndLine/    CMND
                                   
      character*10 fontname(23)
      common /voglefonts/ fontname

      integer*4 i,j,GrNum,FileNum,DefFileNum
      character DataType(10)*11,OnOff*3,YesNo*3,EMGType*7
      logical*4 GetFileNum


      data DataType / 'Motion     ','Electrical ','Force      ','EMG        ',
     &                'Muscle     ','Marker     ','Segment    ','Joint      ',
     &                'Reconstruct','Time       ' /

      DefFileNum= 1
      if ( CMND.NumCmnd .lt. 2 ) goto 1000 ! error
      if ( (CMND.CmndText(2) .eq. 'GEN') .or. 
     &     (CMND.CmndText(2) .eq. 'PAT')      ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        write(6,100) FileNum,FD(FileNum).Name,
     &               FD(FileNum).GP.motion_file,
     &               FD(FileNum).GP.average_file,
     &               FD(FileNum).GP.force_file,
     &               FD(FileNum).GP.last_updated,
     &               FD(FileNum).GP.FileFormatVersion,
     &               FD(FileNum).GP.name,
     &               FD(FileNum).GP.comment,
     &               FD(FileNum).GP.age,
     &               FD(FileNum).GP.Sex,
     &               FD(FileNum).GP.weight,
     &               FD(FileNum).GP.weight*2.22,
     &               FD(FileNum).GP.height,
     &               FD(FileNum).GP.height/.0254
100     format(/' General Information'//
     &          ' File number  : ',i1/
     &          ' Disk file    : ',a40//
     &          ' Motion file  : ',a40/         
     &          ' Average file : ',a40/
     &          ' Force file   : ',a40/
     &          ' Analysis lasted updated : ',a9/
     &          ' ANZ file format version : ',a1//
     &          ' Patient name   : ',a40/
     &          ' Comment        : ',a80/
     &          ' Patient Age    : ',i2/
     &          ' Patient Sex    : ',a1/
     &          ' Patient weight : ',f7.3,' kg   ',f7.3,' lbs'/
     &          ' Patient height : ',f7.3,' m    ',f7.3,' in'   )
                                      
      else if ( CMND.CmndText(2) .eq. 'FIL' ) then
        write(6,103)
103     format(' Files currently available'//' #  Name'/)
        do i= 1, NumFileOpen
          write(6,104) i,FD(i).Name
104       format(1x,i1,2x,a40)
        end do
      else if ( CMND.CmndText(2) .eq. 'MRK' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        write(6,110) FD(FileNum).MP.num_mrk,
     &               YesNo(FD(FileNum).MF.Interpolated),
     &               YesNo(FD(FileNum).MF.Adjusted),
     &               YesNo(FD(FileNum).MF.Smoothed),
     &               YesNo(FD(FileNum).MF.VelAcc),
     &               YesNo(FD(FileNum).MF.Diagnostics),
     &               YesNo(FD(FileNum).MF.Regularized),
     &               FD(FileNum).GP.int_poly_order,
     &               FD(FileNum).MP.num_frm,
     &               FD(FileNum).rMtnFrmRate,
     &               (FD(FileNum).MP.mrk_name(i),i=1,FD(FileNum).MP.num_mrk)
110     format(/' Marker Information'//
     &          ' Number of markers    : ',i2/
     &          ' Markers interpolated : ',a3/
     &          ' Markers adjusted     : ',a3/
     &          ' Markers smoothed     : ',a3/
     &          ' Markers vel/accel    : ',a3/
     &          ' Marker diagnostics   : ',a3/
     &          ' Markers regularized  : ',a3/
     &          ' Order of interp poly : ',i2/ 
     &          ' Number of frames     : ',i3/
     &          ' Frames per second    : ',f8.4/
     &          ' Marker names are     : ',10(a4,1x)/3(25x,10(a4,1x)/)/)
        if ( FD(FileNum).MF.NumProcOps .gt. 0 ) then
          write(6,116) FD(FileNum).MF.ProcOp(1)(1:30) 
116       format(/' Marker smoothing/filtering operations: 'a30)
          do i= 2, FD(FileNum).MF.NumProcOps
            write(6,117) FD(FileNum).MF.ProcOp(i)(1:30)
117         format(41x,a30)
          end do
        end if

      else if ( CMND.CmndText(2) .eq. 'SEG' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        call DisplaySegment( CMND,FileNum )
                                             
      else if ( CMND.CmndText(2) .eq. 'FRC' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        write(6,140) YesNo(FD(FileNum).FF.Read),
     &               YesNo(FD(FileNum).FF.Filtered),
     &               FD(FileNum).FF.FilterOp,
     &               YesNo(FD(FileNum).FF.Adjusted),
     &               YesNo(FD(FileNum).FF.IndFt),
     &               YesNo(FD(FileNum).FF.CpGCS),
     &               YesNo(FD(FileNum).FF.CpLCS),
     &               YesNo(FD(FileNum).FF.CpVelGCS),
     &               YesNo(FD(FileNum).FF.Si),
     &               YesNo(FD(FileNum).FF.Wrench),
     &               YesNo(FD(FileNum).FF.Integral),
     &               YesNo(FD(FileNum).FF.Rec),  
     &               YesNo(FD(FileNum).FF.PitchMomArm),
     &               YesNo(FD(FileNum).FF.PitchWreArm),
     &               YesNo(FD(FileNum).FtOutlineGcsOK(rt)),
     &               YesNo(FD(FileNum).FtOutlineLcsOK(rt))
140     format(' Force Plate Information'//
     &         ' Force data read          : ',a3/
     &         ' Force data filtered      : ',a3/
     &         ' Filter parameters        : ',a40/
     &         ' Forces adjusted          : ',a3/
     &         ' Force split between feet : ',a3/
     &         ' Center of pressure (GCS) : ',a3/
     &         ' Center of pressure (LCS) : ',a3/
     &         ' Center of pressure Vel   : ',a3/
     &         ' Strike Index             : ',a3/
     &         ' Force wrench             : ',a3/
     &         ' GRL Integrals            : ',a3/
     &         ' GRL reconstructed        : ',a3/
     &         ' Pitch Moment Arm         : ',a3/
     &         ' Pitch Wrench Arm         : ',a3/
     &         ' Foot Outline in GCS      : ',a3/
     &         ' Foot Outline in LCS      : ',a3/)
        if ( FD(FileNum).FF.read ) then
          write(6,150) FD(FileNum).FP.num_frm,
     &                 FD(FileNum).FP.frm_rate,
     &                 FD(FileNum).FP.av_frm_ratio,
     &                 FD(FileNum).FP.frm_offset,
     &                 FD(FileNum).FP.num_plt,
     &                 FD(FileNum).FP.FirstFoot,
     &                 FD(FileNum).FP.Direction
150       format(' Number of samples        : ',i4/
     &           ' Samples per second       : ',i4/
     &           ' Analog/video frame ratio : ',f8.5/
     &           ' Analog/video offset      : ',i4/
     &           ' Number of force plates   : ',i2//
     &           ' First foot (GLS)         : ',i4/
     &           ' Direction  (GLS)         : ',i4)
        end if
                                                 
      else if ( CMND.CmndText(2) .eq. 'JNT' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        write(6,160) YesNo(FD(FileNum).JF.AngJCS),
     &               YesNo(FD(FileNum).JF.VelAccJCS),
     &               YesNo(FD(FileNum).JF.AngEUL),
     &               YesNo(FD(FileNum).JF.VelAccEUL),
     &               YesNo(FD(FileNum).JF.Load),
     &               YesNo(FD(FileNum).JF.LegSummed),
     &               YesNo(FD(FileNum).JF.Wrench),
     &               YesNo(FD(FileNum).JF.Power),
     &               YesNo(FD(FileNum).JF.FiniteScrew),
     &               YesNo(FD(FileNum).JF.InstantScrew),
     &               YesNo(FD(FileNum).JF.MomentArm),
     &               YesNo(FD(FileNum).JF.WrenchArm),
     &               YesNo(FD(FileNum).JF.Translation),
     &               YesNo(FD(FileNum).JF.ScrewAngle),
     &               YesNo(FD(FileNum).JF.RefCorrectAng)
160     format(' Joint Information'//                              
     &         ' JCS angles                : ',a3/ 
     &         ' JCS velocity/accel        : ',a3/
     &         ' Euler angles              : ',a3/
     &         ' Euler velocity/accel      : ',a3/
     &         ' Joint reaction loads      : ',a3/
     &         ' Summed leg loads          : ',a3/
     &         ' Joint wrench              : ',a3/
     &         ' Joint power transfer      : ',a3/
     &         ' Joint finite screw        : ',a3/
     &         ' Joint instantaneous screw : ',a3/
     &         ' Joint Moment Arm          : ',a3/
     &         ' Joint Wrench Arm          : ',a3/
     &         ' Joint Translation         : ',a3/
     &         ' Joint finite Screw Angle  : ',a3/
     &         ' Joint Angle Ref Correction: ',a3)
        if ( FD(FileNum).GP.num_jnt .gt. 0 ) then
          write(6,170) FD(FileNum).GP.num_jnt,
     &                 (JntNames(FD(FileNum).GP.jnt_num(i)),
     &                   i=1,FD(FileNum).GP.num_jnt)
170       format(' Number of joints : ',i2/
     &           ' Joint names      : ',6(a4,1x)/20x,6(a4,1x)/20x,6(a4,1x)/ )
        end if
        if ( FD(FileNum).JF.NumProcOps .gt. 0 ) then
          write(6,118) FD(FileNum).JF.ProcOp(1)(1:30) 
118       format(/' Joint smoothing/filtering operations: 'a30)
          do i= 2, FD(FileNum).JF.NumProcOps
            write(6,117) FD(FileNum).JF.ProcOp(i)(1:30)
          end do
        end if
                 
      else if ( CMND.CmndText(2) .eq. 'AVG' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        call DisplayAverage( CMND,FileNum )
                                        
      else if ( CMND.CmndText(2) .eq. 'CYC' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        call DisplayCycle( CMND,FileNum )
                                                            
      else if ( CMND.CmndText(2) .eq. 'EMG' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        if ( FD(FileNum).EF.Read ) then                        
          write(6,200) FD(FileNum).EP.NumChnl,
     &                 FD(FileNum).EP.NumSamples,
     &                 FD(FileNum).EP.SampleRate,
     &                 YesNo(FD(FileNum).EF.Filtered),
     &                 YesNo(FD(FileNum).EF.Rectified),
     &                 YesNo(FD(FileNum).EF.Integrated),
     &                 YesNo(FD(FileNum).EF.Averaged),
     &                 (FD(FileNum).EF.ProcOp(i),i=1,FD(FileNum).EF.NumProcOps)
200       format(' EMG Information'//
     &           ' Number of Channels : ',i2/
     &           ' Number of Samples  : ',i5/
     &           ' Sample Rate        : ',i5,' Hz' //
     &           ' Filtered           : ',a3/
     &           ' Rectified          : ',a3/
     &           ' Integrated         : ',a3/
     &           ' Averaged           : ',a3/
     &           ' Processing Ops     : ',a40/4(22x,a40/) )
          write(6,201)
201       format(' Chnl#   Code#   Type     Name'/)
          do i= 1, FD(FileNum).EP.NumChnl           
            write(6,210) i,FD(FileNum).EP.CodeNum(i),
     &                     EMGType(FD(FileNum).EP.Surface(i)),
     &                     FD(FileNum).EP.Name(i)     
210         format(3x,i2,6x,i2,5x,a7,3x,a20)
          end do ! i
        else
          write(6,220)
220       format(' No EMG information present')
        end if
            
      else if ( CMND.CmndText(2) .eq. 'LIM' ) then
        write(6,560) MAX_MTN_FRM,MAX_ELEC_FRM,MAX_EMG_FRM,
     &               MAX_GRAPH,MAX_PLOT,MAX_PLOT_SIZE,MAX_CHART,
     &               MAX_FILES,MAX_MRK,MAX_EMG
560     format(/' Limits of this version of TELIO'//
     &          '  Max Motion Data Frames : ',i5/
     &          '  Max Force Plate Samples: ',i5/
     &          '  Max EMG Data Samples   : ',i5//
     &          '  Max Graphs per page    : ',i5/
     &          '  Max Data Sets per Graph: ',i5/
     &          '  Max Data Set Size      : ',i5/
     &          '  Max Strips per Chart   : ',i5//
     &          '  Max files              : ',i5/
     &          '  Max Number of Markers  : ',i5/
     &          '  Max Number of EMG''s    : ',i5/)

      else if ( CMND.CmndText(2) .eq. 'GRA' ) then
        if ( CMND.NumCmnd .lt. 3 ) goto 1020 ! not enough commands
        if ( CMND.NumOpt(2) .gt. 0 ) then
          if ( CMND.OptNumOK(1,2) .and.
     &         (CMND.OptIntVal(1,2) .gt. 0) .and.
     &         (CMND.OptIntVal(1,2) .lt. MAX_GRAPH)      ) then
            GrNum= CMND.OptIntVal(1,2)
          else
            goto 1030 ! bad graph number
          end if
        else
          GrNum= 1 ! default graph number
        end if
        if ( CMND.CmndText(3) .eq. 'OPT' ) then
          write(6,230) GrNum,                    
     &                 (OnOff(GROPT(GrNum).Flag(i)),i=1,25),
     &                 GROPT(GrNum).DefFile, 
     &                 FD(GROPT(GrNum).DefFile).Name,
     &                 (GROPT(GrNum).NumDiv(i),i=1,2),
     &                 GROPT(GrNum).Font,fontname(GROPT(GrNum).Font)
230       format(' Graph # ',i1,' options'//
     &           '   Clip to Single Cycle  : ',a3,
     &           '   Remove Average Angle  : ',a3/
     &           '   Print Graph           : ',a3,
     &           '   Display Graph         : ',a3/
     &           '   Display Data Legend   : ',a3,
     &           '   Use Manual Legends    : ',a3/
     &           '   Show Gait Events      : ',a3,
     &           '   Show Percent Cycle    : ',a3/
     &           '   Align Sides           : ',a3,
     &           '   Use lines in plots    : ',a3/
     &           '   Use symbols in plots  : ',a3,
     &           '   Display graph label   : ',a3/
     &           '   Use manual gr label   : ',a3,
     &           '   Normalize by Weight   : ',a3/
     &           '   Normalize by Wt & Ht  : ',a3,
     &           '   Normalize by Wt & Leg : ',a3/
     &           '   Show X Axis Zero Line : ',a3,
     &           '   Show Y Axis Zero Line : ',a3/
     &           '   Positive GRL Fz       : ',a3,
     &           '   Simple Auto Scale     : ',a3/
     &           '   First Plot Events Only: ',a3,
     &           '   Show Foot in CP plot  : ',a3/
     &           '   Show Force Plate in CP: ',a3,
     &           '   Using Postscript Print: ',a3/
     &           '   Manually scale graph  : ',a3/
     &           '   Default File #        : ',i1/
     &           '                Name     : ',a40/    
     &           '   X axis divisions      : ',i2/
     &           '   Y axis divisions      : ',i2/
     &           '   Font Number/Name      : ',i2,' : ',a10)
          if ( GROPT(GrNum).LgndFlg ) write(6,240) GROPT(GrNum).LgndPosNum
240       format('   Legend position #    : ',i2)
          if ( GROPT(GrNum).ManScale ) 
     &      write(6,250) GROPT(GrNum).ManMin(1),GROPT(GrNum).ManMax(1),
     &                   GROPT(GrNum).ManMin(2),GROPT(GrNum).ManMax(2)
250         format(/'   X minimum : ',f10.4,'   X maximum : ',f10.4/
     &              '   Y minimum : ',f10.4,'   Y maximum : ',f10.4)
        else if ( CMND.CmndText(3) .eq. 'DAT' ) then
          write(6,260) GD(GrNum).Title,
     &                 GD(GrNum).SubTitle,
     &                 GD(GrNum).Xtitle,
     &                 GD(GrNum).Ytitle,
     &                 GD(GrNum).GrLabel
260       format(' Graph title        : ',a80/
     &           '       subtitle     : ',a80/
     &           '       x axis label : ',a40/
     &           '       y axis label : ',a40/
     &           '       label        : ',a40//
     &           ' Data Plot Information'/
     &           ' Plot#  Axis ',9x,'Legend',11x,'DataType',5x,'Source File')
          do i= 1, GD(GrNum).NumPlts
            write(6,270) i,PD(i,GrNum).Lgnd(x), 
     &                     DataType(PD(i,GrNum).DataType(x)),
     &                     PD(i,GrNum).File(x)
270         format(3x,i1,6x,'x',2x,a20,2x,a11,2x,a40)
            write(6,280) PD(i,GrNum).Lgnd(y),
     &                   DataType(PD(i,GrNum).DataType(y)),
     &                   PD(i,GrNum).File(y)
280         format(10x,'y',2x,a20,2x,a11,2x,a40)
          end do ! i
        else
          goto 1040 ! invalid OPT GRA command
        end if                              

      else if ( CMND.CmndText(2) .eq. 'SCH' ) then
        write(6,400) (OnOff(CHOPT.Flag(i)),i=1,9),
     &               CHOPT.Title,CHOPT.SubTitle,
     &               CHOPT.XaxisLabel,CHOPT.ChartLabel,
     &               CHOPT.NumXDiv,CHOPT.Font,
     &               CHOPT.Xmin,CHOPT.Xmax
400     format(' StripChart  options'//
     &         '   Display gait events    : ',a3/
     &         '   Display chart title    : ',a3/
     &         '   Display chart label    : ',a3/ 
     &         '   Use manual chart label : ',a3/
     &         '   Use manual X axis scale: ',a3/
     &         '   Simple Auto axis Scale : ',a3/
     &         '   Print chart            : ',a3/
     &         '   Display on screen      : ',a3/
     &         '   Using Postscript Print : ',a3//
     &         '   Title       : ',a40/          
     &         '   Subtitle    : ',a40/
     &         '   X label     : ',a40/          
     &         '   Chart label : ',a40//
     &         '   Num X Divsions : ',i2/
     &         '   Font number    : ',i2//
     &         '   Manual X min   : ',f10.4/
     &         '   Manual X max   : ',f10.4 )

      else if ( CMND.CmndText(2) .eq. 'HIS' ) then
        if ( .not. GetFileNum( CMND.NumOpt(2),CMND.OptNumOK(1,2),
     &                         CMND.OptIntVal(1,2),DefFileNum,
     &                         FileNum )           ) goto 1010 ! error
        call DisplayHistory( FileNum )
                                             
      else if ( CMND.CmndText(2) .eq. '3DP' ) then
        write(6,290)
290     format(' Sorry, not operating yet...')

      else                                   
        write(6,300) CMND.CmndText(2)
300     format(' Error- ',a3,' is not a valid STatus command.'/
     &         '        Available commands are: GENeral MaRKer  SEGment FoRCe'/
     &         '                                JoiNT   AVeraGe CYCle '/
     &         '                                GRAph   3DPlot  HIStory')
      end if            
      return

1000  write(6,1005)
1005  format(' Error- STAtus requires more than one command word.'/
     &       '        Available commands are: GENeral MaRKer     SEGment FoRCe'/
     &       '                                JoiNT   AVeraGe    CYCle'/
     &       '                                GRAph   StripCHart 3DView')
      return

1010  write(6,1015) NumFileOpen
1015  format(' Error- Invalid file number'/
     &       '        Vaild file numbers are from 1 to ',i1)
      return

1020  write(6,1025)
1025  format(' Error- STAtus GRAph requires a third command'/
     &       '        The valid commands are : OPTion  DATa')
      return

1030  write(6,1035) CMND.OptText(1,2),MAX_GRAPH
1035  format(' Error- ',a3,' is not a valid graph number'/
     &       '        Valid graph #''s are 1-',i1)    
      return

1040  write(6,1045) CMND.CmndText(3)
1045  format(' Error- ',a3,' is an invalid STAtus GRAph command'/
     &       '        The valid commands are : OPTion  DATa')
      return
      end
c
c   Copyright (c) 1990 by Dwight Meglan
c       
      subroutine DisplayHistory( FileNum )
      implicit none

      include 'tel_cons.inc'
      include 'tel_strc.inc'
      include 'tel_file.inc'
      include 'tel_name.inc'

      integer*4 FileNum

      integer*4 i,j,k
      character ans*1
     
      k= 0
      do i= 1, FD(FileNum).History(1).NumHistory
        do j= 1, FD(FileNum).History(i).NumLine
          k= k + 1      
          write(6,100) FD(FileNum).History(i).Line(j)     
100       format(1x,a20)
          if ( k .gt. 21 ) then 
            write(6,120)
120         format(/' Press Return to continue...')
            read(5,130) ans
130         format(a1)
            write(6,140)
140         format(/)
            k= 0
          end if       
        end do 
      end do
      return
      end
c
c   Copyright (c) 1990 by Dwight Meglan
c       
      subroutine DisplaySegment( CMND,FileNum )
      implicit none

      include 'tel_cons.inc'
      include 'tel_strc.inc'
      include 'tel_file.inc'
      include 'tel_name.inc'

      record /CmndLine/    CMND
      integer*4 FileNum
                             
      integer*4 i,j,seg
      character*3 YesNo

      if ( CMND.CmndText(3) .eq. 'INE' ) then ! show mass-inertia parameters
        if ( FD(FileNum).SF.Param ) then
          write(6,112)  
112       format(' Segment mass-inertia parameters'/
     &           ' Segment  Mass     Mass moment of inertia'/
     &           '   Name   (kg)     X          Y          Z (kg*m^2)'//)
          do i= 1, FD(FileNum).GP.num_seg
            seg= FD(FileNum).GP.seg_num(i)           
            write(6,114) SegNames(seg),FD(FileNum).SP(seg).mass,
     &                   (FD(FileNum).SP(seg).inertia(j),j=1,3)
114         format(3x,a4,2x,f5.2,3(2x,e9.4))
          end do ! i
        else
          write(6,116)
116       format(' Segment mass-inertia parameters have not been calculated.')
        end if
        
      else ! general segment info
        write(6,120) YesNo(FD(FileNum).SF.Param),
     &               YesNo(FD(FileNum).SF.Pos),
     &               YesNo(FD(FileNum).SF.VelAcc),
     &               YesNo(FD(FileNum).SF.Energy),
     &               YesNo(FD(FileNum).SF.FiniteScrew),
     &               YesNo(FD(FileNum).SF.InstantScrew),
     &               YesNo(FD(FileNum).SF.CntrMass),
     &               YesNo(FD(FileNum).SF.Momentum),
     &               YesNo(FD(FileNum).SF.Angle),
     &               YesNo(FD(FileNum).SF.RefCorrect),
     &               YesNo(FD(FileNum).SF.BCMVel)
120     format(' Segment Information'//
     &         ' Segment parameters          : ',a3/                       
     &         ' Segment position            : ',a3/
     &         ' Segment vel/accel           : ',a3/
     &         ' Segment energy              : ',a3/
     &         ' Segment finite screw        : ',a3/
     &         ' Segment instantaneous screw : ',a3/
     &         ' Body center mass            : ',a3/
     &         ' Segment momentum            : ',a3/
     &         ' Segment angle               : ',a3/
     &         ' Segment pos ref corrected   : ',a3/
     &         ' Body center of mass velocity: ',a3 )
        if ( FD(FileNum).GP.num_seg .gt. 0 ) then
          write(6,130) FD(FileNum).GP.num_seg,
     &                 (SegNames(FD(FileNum).GP.seg_num(i)),i=1,FD(FileNum).GP.num_seg)
130       format(' Number of segments  : ',i2/
     &           ' Segment names       : ',6(a4,1x)/23x,6(a4,1x)/23x,6(a4,1x)/ )
        end if
        if ( FD(FileNum).SF.NumProcOps .gt. 0 ) then
          write(6,140) FD(FileNum).SF.ProcOp(1)(1:30) 
140       format(/' Segment smoothing/filtering operations: 'a30)
          do i= 2, FD(FileNum).SF.NumProcOps
            write(6,150) FD(FileNum).SF.ProcOp(i)(1:30)
150         format(41x,a30)
          end do
        end if
      end if ! mass-inerita parameters or general segment info
      return     
      end
c
c   Copyright (c) 1990 by Dwight Meglan         
c
      subroutine DisplayCycle( CMND,FileNum )
      implicit none

      include 'tel_cons.inc'
      include 'tel_strc.inc'
      include 'tel_file.inc'
      include 'tel_name.inc'

      record /CmndLine/   CMND
      integer*4 FileNum

      integer*4 i       
      real*4    feet,inch
      character ans*1      
                       
      data feet,inch / 3.2808,39.3696 /     ! conversion ft/m, in/m
      
      if ( FD(FileNum).CF.GaitEvent ) then
        write(6,190) ( FD(FileNum).MP.rhs_frm(i),i= 1, FD(FileNum).MP.num_rhs )
190     format(' Cycle event frame #''s'//
     &         ' Right heel strike : ',5(i3,1x) )
        write(6,200) ( FD(FileNum).MP.lhs_frm(i),i= 1, FD(FileNum).MP.num_lhs )
200     format(' Left heel strike  : ',5(i3,1x) )
        write(6,210) ( FD(FileNum).MP.rto_frm(i),i= 1, FD(FileNum).MP.num_rto )
210     format(' Right toe off     : ',5(i3,1x) )
        write(6,220) ( FD(FileNum).MP.lto_frm(i),i= 1, FD(FileNum).MP.num_lto )
220     format(' Left toe off      : ',5(i3,1x) )
        write(6,223) FD(FileNum).MP.first_frm
223     format(/' First motion frame absolute frame # : ',i3/)
        if ( FD(FileNum).CF.Statistics ) then
          write(6,225)
225       format(/' Press return to continue...')
          read(5,227) ans
227       format(a1)        
          write(6,240)
240       format(/' Gait cycle parameters'/)
          write(6,250) FD(FileNum).CP.velocity,        
     &                 FD(FileNum).CP.velocity*feet,
     &                 FD(FileNum).CP.velocity*inch,
     &                 FD(FileNum).CP.NormVelocity,
     &                 FD(FileNum).CP.PctNormVelocity,
     &                 FD(FileNum).CP.stride_length,   
     &                 FD(FileNum).CP.stride_length*feet,
     &                 FD(FileNum).CP.stride_length*inch,
     &                 FD(FileNum).CP.NormStrideLength,
     &                 FD(FileNum).CP.PctNormStrideLength,
     &                 FD(FileNum).CP.step_length(rt), 
     &                 FD(FileNum).CP.step_length(rt)*feet,
     &                 FD(FileNum).CP.step_length(rt)*inch,
     &                 FD(FileNum).CP.NormStepLength(rt),
     &                 FD(FileNum).CP.PctNormStepLength(rt),
     &                 FD(FileNum).CP.step_length(lf), 
     &                 FD(FileNum).CP.step_length(lf)*feet,
     &                 FD(FileNum).CP.step_length(lf)*inch,
     &                 FD(FileNum).CP.NormStepLength(lf),
     &                 FD(FileNum).CP.PctNormStepLength(lf),
     &                 FD(FileNum).CP.step_width,      
     &                 FD(FileNum).CP.step_width*feet,
     &                 FD(FileNum).CP.step_width*inch,
     &                 FD(FileNum).CP.NormStepWidth,
     &                 FD(FileNum).CP.PctNormStepWidth,
     &                 FD(FileNum).CP.cadence, 
     &                 FD(FileNum).CP.NormCadence,
     &                 FD(FileNum).CP.PctNormCadence
250       format(16x,'meters',8x,'feet',8x,'inches',6x,'Normal(m)',3x,'% Normal'//
     &       ' Velocity   : ',5(f8.3,5x)/
     &       ' Stride     : ',5(f8.3,5x)/
     &       ' R Step     : ',5(f8.3,5x)/
     &       ' L Step     : ',5(f8.3,5x)/          
     &       ' Step Width : ',5(f8.3,5x)//
     &       ' Cadence    : ',f8.3,' step/min',22x,2(f8.3,5x)/)
          write(6,260) FD(FileNum).CP.total_time(rt),
     &                 FD(FileNum).CP.total_percent(rt),
     &                 FD(FileNum).CP.NormTotalPct(rt),
     &                 FD(FileNum).CP.total_time(lf),
     &                 FD(FileNum).CP.total_percent(lf),
     &                 FD(FileNum).CP.NormTotalPct(lf),
     &                 FD(FileNum).CP.sgl_time(rt),
     &                 FD(FileNum).CP.sgl_percent(rt),
     &                 FD(FileNum).CP.NormSglPct(rt),
     &                 FD(FileNum).CP.sgl_time(lf),
     &                 FD(FileNum).CP.sgl_percent(lf),
     &                 FD(FileNum).CP.NormSglPct(lf),
     &                 FD(FileNum).CP.dbl_time(rt),  
     &                 FD(FileNum).CP.dbl_percent(rt),
     &                 FD(FileNum).CP.NormDblPct(rt),
     &                 FD(FileNum).CP.dbl_time(lf),
     &                 FD(FileNum).CP.dbl_percent(lf),
     &                 FD(FileNum).CP.NormDblPct(lf)
260       format('            Time (s)        Percent Cycle        Normal'/
     &       ' R TLST  ',3(f8.3,11x)/
     &       ' L TLST  ',3(f8.3,11x)/
     &       ' R SLST  ',3(f8.3,11x)/
     &       ' L SLST  ',3(f8.3,11x)/
     &       ' R DLS   ',3(f8.3,11x)/
     &       ' L DLS   ',3(f8.3,11x)/)       
          if ( FD(FileNum).CP.first_side .eq. rt ) then
            write(6,270) FD(FileNum).CP.HS_percent(1),
     &                   FD(FileNum).CP.NormHsPct(1),
     &                   FD(FileNum).CP.TO_percent(1),
     &                   FD(FileNum).CP.NormToPct(1),
     &                   FD(FileNum).CP.HS_percent(2),
     &                   FD(FileNum).CP.NormHsPct(2),
     &                   FD(FileNum).CP.TO_percent(2),
     &                   FD(FileNum).CP.NormToPct(2),
     &                   FD(FileNum).CP.HS_percent(3),
     &                   FD(FileNum).CP.NormHsPct(3)
270         format(' RHS                        ',f8.3,11x,f8.3/
     &             ' LTO                        ',f8.3,11x,f8.3/
     &             ' LHS                        ',f8.3,11x,f8.3/
     &             ' RTO                        ',f8.3,11x,f8.3/
     &             ' RHS                        ',f8.3,11x,f8.3/ )
          else
            write(6,280) FD(FileNum).CP.HS_percent(1),
     &                   FD(FileNum).CP.NormHsPct(1),
     &                   FD(FileNum).CP.TO_percent(1),
     &                   FD(FileNum).CP.NormToPct(1),
     &                   FD(FileNum).CP.HS_percent(2),
     &                   FD(FileNum).CP.NormHsPct(2),
     &                   FD(FileNum).CP.TO_percent(2),
     &                   FD(FileNum).CP.NormToPct(2),
     &                   FD(FileNum).CP.HS_percent(3),
     &                   FD(FileNum).CP.NormHsPct(3)
280         format(' LHS                        ',f8.3,11x,f8.3/
     &             ' RTO                        ',f8.3,11x,f8.3/
     &             ' RHS                        ',f8.3,11x,f8.3/
     &             ' LTO                        ',f8.3,11x,f8.3/
     &             ' LHS                        ',f8.3,11x,f8.3/ )
          end if ! first_side
        else
          write(6,290)
290       format(/' Cycle Statistics not calculated.')
        end if ! Statistics present
      else                 
        write(6,230)
230     format(' Cycle Information '//
     &         ' Events     : no'/
     &         ' Statistics : no' )
      end if
      return
      end
c
c   Copyright (c) 1990 by Dwight Meglan
c
      subroutine DisplayAverage( CMND,FileNum )
      implicit none
                                       
      include 'tel_cons.inc'
      include 'tel_strc.inc'
      include 'tel_file.inc'
      include 'tel_name.inc'
                                      
      record /CmndLine/   CMND
      integer*4 FileNum

      integer*4 i,seg,j,k,jnt
      character*3 YesNo
                 
      if ( CMND.CmndText(3) .eq. 'POS' ) then
        if ( .not. FD(FileNum).AF.Pos ) goto 1000
        if ( (CMND.NumCmnd .eq. 3) .or. (CMND.CmndText(4) .eq. 'CNT') ) then
          write(6,110)           
110       format(/' Segment average location'//
     &            ' Segment          Position (m)'/
     &            '  Name        X       Y      Z'/)
          do i= 1, FD(FileNum).GP.num_seg
            seg= FD(FileNum).GP.seg_num(i)
            write(6,120) SegNames(seg),(FD(FileNum).AvgSegPos(j,cntr,seg),j=x,z)
120         format(2x,a4,5x,3(f7.3))
          end do ! i
        else
          write(6,130)
130       format(/' Segment average orientation'//
     &            ' Segment          X                    Y                  Z'/
     &            '  Name     ',3('x      y      z      ')/)
          do i= 1, FD(FileNum).GP.num_seg           
            seg= FD(FileNum).GP.seg_num(i)
            write(6,140) SegNames(seg),
     &                   ((FD(FileNum).AvgSegPos(j,k,seg),j=x,z),k=x,z)
140         format(2x,a4,5x,9(f7.3))
          end do                                            
        end if ! center or orientation
        
      else if ( CMND.CmndText(3) .eq. 'ANG' ) then
        if ( (CMND.NumCmnd .eq. 3) .or. (CMND.CmndText(4) .eq. 'JCS') ) then
          if ( .not. FD(FileNum).AF.AngJCS ) goto 1010
          write(6,150)
150       format(/' Average JCS joint angle'//
     &            ' Joint           Angle'/
     &            ' Name       Flex    Inex    Abad'/)
          do i= 1, FD(FileNum).GP.num_jnt                 
            jnt= FD(FileNum).GP.jnt_num(i)
            write(6,160) JntNames(jnt),(FD(FileNum).AvgJntAngJCS(j,jnt),j=1,3)
160         format(1x,a4,4x,3f8.2)
          end do ! i     
        else 
          if ( .not. FD(FileNum).AF.AngEUL ) goto 1020
          write(6,170)
170       format(/' Average euler joint angle'//
     &            ' Joint           Angle'/
     &            ' Name       Flex    Inex    Abad'/)
          do i= 1, FD(FileNum).GP.num_jnt                
            jnt= FD(FileNum).GP.jnt_num(i)
            write(6,160) JntNames(jnt),(FD(FileNum).AvgJntAngEUL(j,jnt),j=1,3)
          end do ! i
        end if ! JCS or euler angles
        
      else if ( CMND.NumCmnd .eq. 2 ) then
        write(6,100) FD(FileNum).GP.average_file,
     &               YesNo(FD(FileNum).AF.Pos),
     &               YesNo(FD(FileNum).AF.AngEUL),
     &               YesNo(FD(FileNum).AF.AngJCS),
     &               YesNo(FD(FileNum).AF.RefCorrectAng)
100     format(' Average information'//           
     &         ' Source file       : ',a40/            
     &         ' Position          : ',a3/
     &         ' JCS angles        : ',a3/
     &         ' Euler angles      : ',a3/
     &         ' Ref Pos Corrected : ',a3 )
     
      else
        write(6,180)
180     format(' Error- Invalid STAtus AVeraGe command.'/
     &         '        Valid commands are: POS CeNTer'/
     &         '                                ORIentation'/
     &         '                            ANGle JCS'/
     &         '                                  EULer')
      end if
      return

1000  write(6,1005)
1005  format(' Error- Average segment position has not been calculated yet.')
      return
      
1010  write(6,1015)
1015  format(' Error- Average JCS joint angles have not been calculated yet.')
      return
      
1020  write(6,1025)
1025  format(' Error- Average euler joint angles have not been calculated yet.')
      return
      end

      function YesNo( Flag )
      implicit none

      character*3 YesNo
      logical*4   Flag

      if ( Flag ) then
        YesNo= 'yes'
      else
        YesNo= 'no '
      end if
      return
      end


      function OnOff( Flag )
      implicit none

      character*3 OnOff
      logical*4   Flag

      if ( Flag ) then
        OnOff= 'on '
      else
        OnOff= 'off'
      end if
      return
      end


      function EMGType( Flag )
      implicit none

      character*7 EMGType
      logical*4   Flag

      if ( Flag ) then
        EMGType= 'Surface'
      else
        EMGType= 'Wire   '
      end if
      return
      end
