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
|
#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3 2003/03/13 09:00:22 peterg
## Revised for new mtt_component_eqn arg list
##
## Revision 1.2 2003/03/11 10:16:03 peterg
## Removed NAME argument
##
## Revision 1.1 2003/03/11 10:08:49 peterg
## Initial revision
##
##
###############################################################
## cbg2seqn_m2r: Converts causal bond graph into sorted equations
## Copyright (C) 2003 by Peter J. Gawthrop
strucfile=$1_struc.txt
outfile=$1_sese.r
make=mtt_make_sese.m
CD='%%%% ====='
## Inform user
echo Creating ${outfile}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
37
38
39
40
41
42
43
44
45
46
47
48
|
#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1 2003/03/13 15:44:53 gawthrop
## The main transformation for sorted elementary equations
##
## Revision 1.3 2003/03/13 09:00:22 peterg
## Revised for new mtt_component_eqn arg list
##
## Revision 1.2 2003/03/11 10:16:03 peterg
## Removed NAME argument
##
## Revision 1.1 2003/03/11 10:08:49 peterg
## Initial revision
##
##
###############################################################
## cbg2seqn_m2r: Converts causal bond graph into sorted equations
## Copyright (C) 2003 by Peter J. Gawthrop
while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
-I )
info=info;;
*)
echo "$1 is an invalid argument - ignoring" ;;
esac
shift
done
infofile='mtt_info.txt';
strucfile=$1_struc.txt
outfile=$1_sese.r
make=mtt_make_sese.m
CD='%%%% ====='
## Inform user
echo Creating ${outfile}
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
## Create the octave commands for state, output etc
create_octave() {
gawk '{
if ($1==which) {
printf("printf(\"\\n%s The %s equation for %s\");\n", CD, $1, $4);
printf("[known] = mtt_component_eqn\\\n");
printf("(\"%s\",1,mtt_other_causality(\"%s\"),known);\n", $4, $6);
}
}' "CD=${CD}" which=$1 < ${strucfile}
}
create_octave_header() {
cat <<EOF
## Octave commands to generate sese file
|
|
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
## Create the octave commands for state, output etc
create_octave() {
gawk '{
if ($1==which) {
printf("printf(\"\\n%s The %s equation for %s\");\n", CD, $1, $4);
printf("[known] = mtt_component_eqn\\\n");
printf("(\"%s\",1,mtt_other_causality(\"%s\"),known,\"\",\"\");\n", $4, $6);
}
}' "CD=${CD}" which=$1 < ${strucfile}
}
create_octave_header() {
cat <<EOF
## Octave commands to generate sese file
|
120
121
122
123
124
125
126
|
for which in ${which_list}; do
set_out ${which} >> ${outfile}
done
cat<<EOF >> ${outfile}
END;
EOF
|
>
>
>
>
>
>
|
134
135
136
137
138
139
140
141
142
143
144
145
146
|
for which in ${which_list}; do
set_out ${which} >> ${outfile}
done
cat<<EOF >> ${outfile}
END;
EOF
## Print info
if [ "$info" = "info" ]; then
cat $infofile
fi
|