File mttroot/mtt/bin/trans/abg2lbl_fig2txt artifact 53ebf0e810 part of check-in 1ac694cfc9


#! /bin/sh

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

# Bourne shell script: abg2lbl_fig2txt
#
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1997/03/19  12:08:01  peterg
# No longer writes out non-unique names - now done in rbg_fig2m
#
# Revision 1.1  1997/03/18  13:55:01  peterg
# Initial revision
#
###############################################################


# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997

infofile='mtt_info.txt'
typefile="$1_type.sh"

# Remove the old log file
rm -f abg2lbl_fig2txt.log
rm -f $1_cbg.m
rm -f $typefile
rm -f $infofile


#Inform user
echo Creating $1_lbl.txt

	( \
	echo "%SUMMARY $1: <brief description here>"; \
	echo "%DESCRIPTION <Detailed description here>"; \
	echo "%% Label file for system $1 ($1_lbl.txt)"; \
	cat $MTTPATH/trans/m/rcs_header.txt; \
	echo "%% Each line should be of one of the following forms:"; \
	echo "%	a comment (ie starting with %)"; \
	echo "%	Component-name	CR_name	arg1,arg2,..argn"; \
	echo "%	blank"; \
	echo; \
        echo \
        )> $1_lbl.txt

awk '/:/ {print $NF}' $1_abg.fig | \
sed 's/\\001//' | \
sort | \
tee $1_raw_list | \
sort -u> $1_unique_raw_list

#Write out non-unique names
#echo 'Non-unique names (if any):'
#diff $1_unique_raw_list  $1_raw_list | grep '>' | sed 's/>/	/'

#Write out the outline lbl file
grep -v  '\[[0-9]*\]'  $1_unique_raw_list | \
awk --field-separator ':' \
 '{ \
   if (($1 !~ "0")&&($1 !~ "1")) \
    { if (Component !~ $1) print "\n% Component type", $1
    if ($1 ~ "SS") \
	print  "\t" $2 "\t\texternal\texternal";
	else \
	print  "\t" $2"\t\tlin\tflow," $2} \
   else {
         if (Component !~ $1) print "\n% Component type", $1; \
	 print  "\t" $2;
	}
        Component=$1\
 }' \
>>$1_lbl.txt



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