Differences From Artifact [d6fcd84bcc]:

To Artifact [feddc6f59d]:


9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.5  1998/03/02 09:26:18  peterg
## Now does default CR and args for the basic components only
## SS,I,R,C,GY,TF
## C now has a default of effort input.
##
## Revision 1.4  1998/02/23 16:20:33  peterg
## Summary line just contains the model name







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/03/05 10:09:47  peterg
## Corrected bug in writing "other" components
##
## Revision 1.5  1998/03/02 09:26:18  peterg
## Now does default CR and args for the basic components only
## SS,I,R,C,GY,TF
## C now has a default of effort input.
##
## Revision 1.4  1998/02/23 16:20:33  peterg
## Summary line just contains the model name
40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55
56




57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

84
85

86

87
88

89

90
91

92

93
94

95

96
97

98

99

100
101
102
103









104



105



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"; \
	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 if ($1 ~ "R") 

	print  "\t" $2"\t\tlin\tflow," $2;


      else if ($1 ~ "I") 

	print  "\t" $2"\t\tlin\tflow," $2;


      else if ($1 ~ "C") 

	print  "\t" $2"\t\tlin\teffort," $2;


      else if ($1 ~ "TF") 

	print  "\t" $2"\t\tlin\tflow," $2;


      else if ($1 ~ "GY") 

	print  "\t" $2"\t\tlin\tflow," $2;

      else
	 print  "\t" $2;
	}
        Component=$1









 }' >>$1_lbl.txt














|





>


<

>
>
>
>

|
|
|

|
|















|



|
>
|
|
>
|
>

|
>
|
>

|
>
|
>

|
>
|
>

|
>
|
>

>


|
|
>
>
>
>
>
>
>
>
>
|
>
>
>
|
>
>
>
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
rm -f mtt_junk*

#Inform user
echo Creating $1_lbl.txt

	( \
	echo "%% Label file for system $1 ($1_lbl.txt)"; \
	echo "%SUMMARY $1"; \
	echo "%DESCRIPTION <Detailed description here>"; \

	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

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") {
	port_alias[++j] = $2
	print  "\t" $2 "\tSS\t\texternal,external";
      }

      else if ($1 == "R") {
	alias[++i] = $2
	print  "\t" $2"\t\tlin\tflow," $2;
      }

      else if ($1 == "I") {
	alias[++i] = $2
	print  "\t" $2"\t\tlin\tflow," $2;
      }

      else if ($1 == "C") {
	alias[++i] = $2
	print  "\t" $2"\t\tlin\teffort," $2;
      }

      else if ($1 == "TF") {
	alias[++i] = $2
	print  "\t" $2"\t\tlin\tflow," $2;
      }

      else if ($1 == "GY") {
	alias[++i] = $2
	print  "\t" $2"\t\tlin\tflow," $2;
      }
      else
	 print  "\t" $2;
      }
      Component=$1
  }
  END{
    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);
        print "%ALIAS\t" port_name "\t" port_name >> "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";
    }
 }' > mtt_junk_body.txt

cat mtt_junk_top.txt mtt_junk_alias.txt mtt_junk_blurb.txt mtt_junk_body.txt > $1_lbl.txt

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