File mttroot/mtt/bin/trans/abg2cmp_fig2txt artifact 8f79e32c94 part of check-in d5b5ecde7c


#! /bin/sh

### abg2cmp_fig2txt
##  Creates list of components contained in _abg.fig
## Copyright (C) 2002 by Peter J. Gawthrop

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Log$
  ## Revision 1.2  2002/12/06 11:47:49  gawthrop
  ## Checks levels in fig file to extract genuine components
  ## Puts comments at top of cmp.txt file
  ##
  ## Revision 1.1  2002/12/01 14:54:39  gawthrop
  ## Replaces defunct abg2lbl_fig2txt
  ##
  ##
  ###############################################################

system=$1
infile=${system}_abg.fig
outfile=${system}_cmp.txt
date=`date`

echo Creating ${outfile}

header() {
    cat <<EOF
## List of components contained in system ${system}
## File ${outfile}
## Created by mtt on ${date}

EOF
}
get_valid_components()

{
gawk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;
  length_terminator=4;

}
{
  object = $1;
  zero_depth =  (modulo10($4)==0)&&(object==text);
  if (zero_depth) {
    print substr($NF,1,length($NF)-length_terminator)
  }
}' 

}

remove_port_labels() {
  grep -v '^\[.*\]$'
}

remove_junctions() {
  grep -v '^[01]$' 
} 

## Create header
header > ${outfile}

## Make list of components
get_valid_components < ${infile} |\
   remove_port_labels |\
   remove_junctions |\
   sort >> ${outfile}


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