Differences From Artifact [7cf338a0f7]:

To Artifact [05944f3223]:


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.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







>
>
>
>
>







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

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

# 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







|







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 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

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

create_lbl_body()
{


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









>
>







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
  }
  else {
    alias[++i] = Name;
    if (length(sensitivity)>0) {
      s_arg = sprintf("%ss",Name);
      alias[++i] = s_arg;
      s_arg = sprintf(";%s",s_arg);

      Component = substr(Component,2);
      lin = "slin"
    }
   else {

      lin = "lin"
    }
  
 }

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








>




>
|







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";
    }
  
 }

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

  ## Component
    printf("\t%s\t", Name);
    if (Component in cr)
      printf("%s\t\t", cr[Component])
    else 
      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")
    }

    OldComponent=Component;
    delete arg[Component]; # Zap the element
    delete cr[Component]; # Zap the element
  }
  END{







|
|

|




|




|







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";
    }

  ## Print component header 
  if (Component !~ OldComponent) print "\n## Component type", Component_type

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

   if (Component in arg)
      printf("%s\t\t\n", arg[Component])
    else {
	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




#    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()
{
cat <<EOF

## Argument aliases
EOF

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

## Main 

create_lbl_body $1> mtt_junk_lbl.txt



write_header            > ${outfile}
cat mtt_junk_alias.txt >> ${outfile}
create_args mtt_junk   >> ${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*












|





<
|
|




|
>
>



|









>
>
>
>
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_arg_aliases()
{
cat <<EOF

## Argument aliases
EOF

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

## Main 

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}
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*






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