Index: mttroot/mtt/bin/trans/abg2lbl_fig2txt ================================================================== --- mttroot/mtt/bin/trans/abg2lbl_fig2txt +++ mttroot/mtt/bin/trans/abg2lbl_fig2txt @@ -11,10 +11,15 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.16 2001/06/11 19:43:49 gawthrop +## MTT is now much more sophisticated in generating lbl files +## Labels can contain maths +## Repetative components are now broken +## ## Revision 1.15 2001/06/11 16:53:49 gawthrop ## Now uses abg2sympar_m2txt to get the arguments ## ## Revision 1.14 2001/06/11 15:06:58 gawthrop ## Now handles user-defined components @@ -70,18 +75,19 @@ # Copyright (c) P.J.Gawthrop, 1997 infofile='mtt_info.txt' typefile="$1_type.sh" sensitivity=$2; +system=$1 +outfile=$1_lbl.txt # Remove the old log file rm -f abg2lbl_fig2txt.log rm -f $1_cbg.m rm -f $typefile rm -f $infofile rm -f mtt_junk* - ## Create lbl files beneath this one mtt -q -u -l 1 $1 sub sh # Create the list sh $1_sub.sh "abg2lbl_fig2txt " @@ -92,32 +98,42 @@ ##echo "$1_lbl.txt dosn not exist in `pwd` " fi #Inform user if [ -n "$sensitivity" ]; then - echo "Creating $1_lbl.txt (sensitivity version)" + echo "Creating ${outfile} (sensitivity version)" else - echo "Creating $1_lbl.txt" + echo "Creating ${outfile}" fi - ( \ - echo "%% Label file for system $1 ($1_lbl.txt)"; \ - echo "%SUMMARY $1"; \ - echo "%DESCRIPTION "; \ - cat $MTTPATH/trans/m/rcs_header.txt; \ - )>mtt_junk_top.txt - - ( \ - echo; \ - 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 "% ---- Component labels ----"; \ - )> mtt_junk_blurb.txt - +write_header() + +{ +cat< $1_unique_raw_list @@ -133,12 +149,11 @@ OldComponent="None"; } { Component = $1; Name = $2; - name = Name; - gsub(/[()-+*/]/,"",name); # Remove maths + Arg = $3; ##Aliases if (Component == "SS") { port_alias[++j] = Name; } @@ -183,16 +198,24 @@ cr["CDx"] = "lin"; arg["CDx"] = sprintf("%s%s", Name, s_arg); cr["RS"] = lin; arg["RS"] = sprintf("flow,%s%s", Name, s_arg); + ## Put in the explicit arguments + if (length(Arg)>0) { + arg[Component] = Arg; + if (match(Arg,"=")>0) # Its an equation type cr + cr[Component] = "cr" + else # assume a linear cr + cr[Component] = "lin"; + } ## Heading - if (Component !~ OldComponent) print "\n% Component type", Component + if (Component !~ OldComponent) print "\n## Component type", Component ## Component - printf("\t%s\t", name); + printf("\t%s\t", Name); if (Component in cr) printf("%s\t\t", cr[Component]) else printf("none\t\t"); @@ -203,38 +226,50 @@ } OldComponent=Component; } END{ - print "\n% Port aliases" >> "mtt_junk_alias.txt"; + print "\n## Port aliases" >> "mtt_junk_alias.txt"; for (k=1;k<=j;k++){ if (port_alias[k] ~ "\\["){ # Only do ports port_name = substr(port_alias[k],2,length(port_alias[k])-2); if (length(sensitivity)==0) - print "%ALIAS\t" port_name "\t" port_name >> "mtt_junk_alias.txt"; + print "#ALIAS\t" port_name "\t" port_name >> "mtt_junk_alias.txt"; else - print "%ALIAS\t" port_name "\t" port_name "_1," port_name "_2" >> "mtt_junk_alias.txt"; + print "#ALIAS\t" port_name "\t" port_name "_1," port_name "_2" >> "mtt_junk_alias.txt"; } } # print "\n% Argument aliases" >> "mtt_junk_alias.txt"; # for (k=1;k<=i;k++){ # print "%ALIAS\t\$" k "\t" alias[k] >> "mtt_junk_alias.txt"; # } - }' sensitivity=$sensitivity > $1_lbl.txt - + }' sensitivity=$sensitivity +} -## Create argument aliases -cat > mtt_junk_arg_alias.txt<> mtt_junk_arg_alias.txt + awk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}' +} + +## Main + +create_lbl_body $1> mtt_junk_lbl.txt -mv $1_lbl.txt mtt_junk_body.txt +write_header > ${outfile} +cat mtt_junk_alias.txt >> ${outfile} +create_args mtt_junk >> ${outfile} +write_blurb >> ${outfile} +cat mtt_junk_lbl.txt >> ${outfile} -cat mtt_junk_top.txt mtt_junk_alias.txt mtt_junk_arg_alias.txt mtt_junk_blurb.txt mtt_junk_body.txt > $1_lbl.txt +## Clean up +rm -f mtt_junk* + Index: mttroot/mtt/bin/trans/awk/rbg_fig2m.awk ================================================================== --- mttroot/mtt/bin/trans/awk/rbg_fig2m.awk +++ mttroot/mtt/bin/trans/awk/rbg_fig2m.awk @@ -10,10 +10,15 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.40 2001/06/11 19:43:50 gawthrop +## MTT is now much more sophisticated in generating lbl files +## Labels can contain maths +## Repetative components are now broken +## ## Revision 1.39 2001/05/09 08:50:02 gawthrop ## Uses _art.fig to transmit the art work to the cbg.fig rep. ## ## Revision 1.38 2001/03/23 14:57:31 gawthrop ## Now puts space after header fields + writes _port.fig @@ -271,11 +276,18 @@ # It is terminated by \001 - so delete this termination str = substr(str,1,length(str)-4); # Zap maths - gsub(/[()-+*/]/,"",str); + ##gsub(/[()-+*/]/,"",str); + +# Loose the cr stuff (if present) + if (depth==0) { + N=split(str,a,delimiter); + if (N==3) + str=sprintf("%s%s%s", a[1],delimiter,a[2]); + } # A component string contains only alphanumeric _ and : isa_plain_component = match(str, component_regexp)==0; # It must also be specified at depth 0 (modulo 10) isa_plain_component = isa_plain_component && (depth==0);