Overview
Comment:Fixed a bug: abg2sympar_m2txt neads a _lbl.txt file when using
"usinglabel" option
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: a2e68605d6f053130cc1672d8cfb504c3d5ed633ae80588666ba5685a3a3d51e
User & Date: gawthrop@users.sourceforge.net on 2001-07-08 03:28:11
Other Links: branch diff | manifest | tags
Context
2001-07-08
03:32:36
Moved in""; command from lbl to cr check-in: 3e33da538c user: gawthrop@users.sourceforge.net tags: origin/master, trunk
03:28:11
Fixed a bug: abg2sympar_m2txt neads a _lbl.txt file when using
"usinglabel" option
check-in: a2e68605d6 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2001-07-06
08:07:45
Added rep for documentation check-in: 52abf1ed63 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/abg2lbl_fig2txt from [7cf338a0f7] to [05944f3223].

9
10
11
12
13
14
15





16
17
18
19
20
21
22
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27







+
+
+
+
+







# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.21  2001/07/06 00:46:50  gawthrop
## Added -cr option -- forces cr to be loaded before the ese.r file
## This avoids causality problems when using multi-port Rs to represent
## arbitary equations
##
## Revision 1.20  2001/07/04 05:19:57  gawthrop
## Added RT & CT to list
##
## Revision 1.19  2001/07/03 23:51:10  gawthrop
## Now puts outline #Summary and #Description lines at top of lbl file
##
## Revision 1.18  2001/06/13 18:24:10  gawthrop
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115







-
+








if [ -n "$sensitivity" ]; then
    sys="-s ${system}"
else
    sys=${system}
fi

# Remove the old log file
# Remove unwanted files
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
153
154
155
156
157
158
159


160
161
162
163
164
165
166
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173







+
+








## ---- Component labels ----
EOF
}

create_lbl_body()
{

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


186
187
188
189
190
191
192

193
194
195
196

197

198
199
200
201
202
203
204
193
194
195
196
197
198
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213







+




+
-
+







  }
  else {
    alias[++i] = Name;
    if (length(sensitivity)>0) {
      s_arg = sprintf("%ss",Name);
      alias[++i] = s_arg;
      s_arg = sprintf(";%s",s_arg);
      Component_type = Component;
      Component = substr(Component,2);
      lin = "slin"
    }
   else {
      Component_type = Component;
      lin = "lin"
      lin = "lin";
    }
  
 }

    ## Table of components
    cr["SS"] = "SS";  arg["SS"] = "external,external";

234
235
236
237
238
239
240
241
242


243
244

245
246
247
248
249

250
251
252
253
254

255
256
257
258
259
260
261
243
244
245
246
247
248
249


250
251
252

253
254
255
256
257

258
259
260
261
262

263
264
265
266
267
268
269
270







-
-
+
+

-
+




-
+




-
+







      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
  ## Print component header 
  if (Component !~ OldComponent) print "\n## Component type", Component_type

  ## Component
  ## Print Component
    printf("\t%s\t", Name);
    if (Component in cr)
      printf("%s\t\t", cr[Component])
    else 
      printf("%s\t\t",default_cr);
      printf("%s\t\t", default_cr);

   if (Component in arg)
      printf("%s\t\t\n", arg[Component])
    else {
	print "lbl2args_txt2out", Component | "/bin/sh"; close("/bin/sh")
	print "lbl2args_txt2out", Component_type | "/bin/sh"; close("/bin/sh")
    }

    OldComponent=Component;
    delete arg[Component]; # Zap the element
    delete cr[Component]; # Zap the element
  }
  END{
273
274
275
276
277
278
279
280

281
282
283
284
285
286
287
288


289
290
291
292
293



294
295
296
297

298
299
300
301
302
303
304
305
306




282
283
284
285
286
287
288

289
290
291
292
293
294



295
296
297
298
299
300

301
302
303
304
305
306

307
308
309
310
311
312
313
314
315
316
317
318
319
320







-
+





-
-
-
+
+




-
+
+
+



-
+









+
+
+
+
#    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
}

create_args()
create_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF

abg2sympar_m2txt $1 "" use_label_file |\
 awk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
abg2sympar_m2txt ${system} ${system} use_label_file |\
awk '{printf("#ALIAS\t$%i\t%s\n", ++i, $1)}'
}

## Main 

create_lbl_body $1> mtt_junk_lbl.txt
create_lbl_body $1> $1_lbl.txt
create_arg_aliases > mtt_args.txt # using $1_lbl.txt
mv $1_lbl.txt mtt_junk_lbl.txt

write_header            > ${outfile}
cat mtt_junk_alias.txt >> ${outfile}
create_args mtt_junk   >> ${outfile}
cat mtt_args.txt       >> ${outfile}
write_blurb            >> ${outfile}
cat mtt_junk_lbl.txt   >> ${outfile}
## Put a blank line at end
cat >> ${outfile} <<EOF

EOF
## Clean up
rm -f mtt_junk*





Modified mttroot/mtt/bin/trans/abg2sympar_m2txt from [a7c4d6974d] to [e5a3769ca7].

1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24

25
26
27
28

29
30
31
32
33
34
35
1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
35
36












-
+










-
+




+







#! /bin/sh

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

# Bourne shell script: abg2sympar_m2txt

# Label file to symbolic parameters conversion
# Copyright (C) 2000 by Peter J. Gawthrop

# Inform user
#echo "Creating $1_sympar.txt"
##echo "Creating $1_sympar.txt" with $1 $2 $3

# Separation characters
SEPS='^=*;+/()-'
# Replace by ,
REPS='[,*]'

SystemName=$2
UseLabelFile=$3

if [ -n "$UseLabelFile" ]; then ## Take input from lbl.txt
     strip_comments < $1_lbl.txt | tr $SEPS $REPS |\
     strip_comments < $1_lbl.txt  | tr $SEPS $REPS |\
     awk '{printf("%s %s \"%s\",\n",$1,$2,$3)}' > mtt_stripped_file
else ## Take input from _abg.m
     cat $1_abg.m | grep "arg =" | tr $SEPS $REPS > mtt_stripped_file
fi

rm -f mtt_error
# This is the main transformation using gawk
cat mtt_stripped_file | \
awk '
function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
}


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