File mttroot/mtt/bin/trans/abg2tex artifact f4bd38e131 part of check-in b307857564


#!/bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: abg2tex
# Creates a tex file describing the system abg
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/11/27 17:45:00  peterg
## Removed "System" from  heading
##
## Revision 1.1  2000/11/27 15:11:15  peterg
## Initial revision
##
## Revision 1.7  1997/12/06 16:20:37  peterg
## Added another argument - the label
##
## Revision 1.6  1997/12/06 15:49:35  peterg
## Changed order of fig arguments to put filename first.
##
## Revision 1.5  1997/08/15 11:32:05  peterg
## Removed an echo left in by mistake
##
# Revision 1.4  1997/08/15  11:19:25  peterg
# Minto cosmetics.
#
## Revision 1.3  1997/05/21 12:07:22  peterg
## Replaced echo by cat -- much simpler.
##
## Revision 1.2  1997/05/19 16:25:53  peterg
## Explicit include of tex files .. latex2html seems to prefer this!
##
# Revision 1.1  1997/05/19  11:30:00  peterg
# Initial revision
#
###############################################################

#Look for a command line argument
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-pdf )  pdf='-pdf'
                ;;
	-s )  sensitivity='-s'
                ;;

	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done


if [ -z "$2" ]; then
  filename="$1_abg.tex";
  echo > $filename
  echo Creating $filename
  subsection='section'
else
  filename=$2
  subsection='subsection'
fi


#Section heading (if not at top level)
if [ -n "$2" ]; then
cat<<EOF >> $filename

%% Subsystem $1
  \subsection{\textbf{$1}}
    \label{sec:$1}
    \index{\textbf{$1} -- abg} 

EOF
else
mtt -q -u ${sensitivity} $1 abg m # Make sure all the subsystems exist -- nasty kludge
cat<<EOF > $filename
   % abg report for system $1 ($filename)
   % Generated by MTT at `date`
EOF
fi

# Figure
##echo mtt -q -u $pdf $1 abg ps
mtt -q -u  $pdf $1 abg ps
cat <<EOF  >> $filename

   \fig{`pwd`/$1_abg}{$1_abg.ps}{0.9}{System \textbf{$1}: acausal bond graph}

EOF

# Description
mtt -q -u $1 desc tex
# Put in absolute pathnames in figures -- and fix bug in old desc files
sed "s;fig{;fig{`pwd`/;g" < $1_desc.tex |\
sed "s/Ref{$1_abg}/Ref{fig:$1_abg.ps}/" >> $filename

# Label file
mtt -q -u $1 lbl tex
cat<<EOF  >> $filename
 \sub$subsection{Summary information} 
 \label{sec:$1_lbl} 
 \index{\textbf{$1} -- lbl} 
EOF
cat $1_lbl.tex   >> $filename


# CRs
#mtt -q -u $1 cr tex
#cat<<EOF  >> $filename
# \sub$subsection{Constitutive relationships} 
# \label{sec:$1_cr} 
# \index{\textbf{$1} -- cr} 
#EOF
#cat $1_cr.tex   >> $filename

# Subsystems
mtt -q -u $1 sub tex 
cat<<EOF  >> $filename
 \sub$subsection{Subsystems} 
 \label{sec:$1_sub} 
 \index{\textbf{$1} -- subsystems} 
EOF
cat $1_sub.tex   >> $filename

#Now do the subsystems (if at top level)
if [ -z "$2" ]; then
 sub2subs $1 | sort -u | \
  awk '{print "abg2tex", pdf, $1, filename}' pdf=$pdf filename=$filename | sh
fi













MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]