12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
+
+
+
|
###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$
## Revision 1.15 1998/07/08 14:43:12 peterg
## Restored inforfile
##
## Revision 1.14 1998/07/08 08:26:26 peterg
## Added -I option -- if set prints out the information messages
##
## Revision 1.13 1998/05/12 14:49:10 peterg
## Don't write END; any more - ese-tidy does this now!
##
## Revision 1.12 1998/01/23 13:30:46 peterg
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
+
+
+
+
|
##
###############################################################
while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
-I )
info=info;;
-partition )
partition=yes;
blurb='with partitioning';
;;
*)
echo "$1 is an invalid argument - ignoring" ;;
esac
shift
done
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
-
+
|
rm -f mtt_info.txt
rm -f mtt_error.txt
# Remove relevent ese files
rm -f $1_ese.r $1_*_ese.r
#Inform user
echo Creating $eqnfile
echo Creating $eqnfile $blurb
echo Creating $deffile
echo Creating $structurefile
# Use matrix manipulation to accomplish the transformation
$MATRIX << EOF > cbg2ese_m2r.log 2>mtt_error.txt
infofile = '$infofile';;
|
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
140
141
142
143
144
145
146
147
148
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
-
+
-
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
|
system_args = '';
full_name = '';
full_name_repetition = '';
% Structure matrix [states,nonstates,inputs,outputs,zero_outputs]
structure = zeros(1,6);
structure = zeros(1,7); # Initialise structure vector
structure = cbg2ese(system_name, system_type, system_cr, ...
system_args, full_name, full_name_repetition, ...
1, structure, structurefilenum, infofilenum);
makedef(structure,deffilenum);
EOF
if [ "$info" = "info" ]; then
cat $infofile
fi
if [ -z "$partition" ]; then
# Don't partition
# Create the composite ese file
cat $1_ese.r $1_*_ese.r > $1_ese.tmp 2>> /dev/null
# Create the composite ese file
cat $1_ese.r $1_*_ese.r > $1_ese.tmp 2>> /dev/null
mv $1_ese.tmp $1_ese.r
mv $1_ese.tmp $1_ese.r
# Zap the sub ese files
rm -f $1_*_ese.r
# Zap the sub ese files
rm -f $1_*_ese.r
else # Partition the system
# Find subsystems
subsystems=`mtt_get_subsystems $1`
# Top level
# The top-level definition file
Nx=`mtt_getsize -external $1 x`
Nz=`mtt_getsize -external $1 z`
Ny=`mtt_getsize -external $1 y`
Nu=`mtt_getsize -external $1 u`
Nui=`mtt_getsize -external $1 ui`
Nuc=`mtt_getsize -internal $1 u`
echo Ny $Ny Nu $Nu Nx $Nx Nui $Nui Nuc $Nuc
## Definitions file
octave -q <<EOF
deffile = '$1_def.r';
deffilenum = fopen(deffile,'w');
## Set up the structure vector
structure = zeros(1,7);
structure(1) = $Nx; # States
structure(2) = $Nz; # Non-states
structure(3) = $Nu; # Inputs
structure(4) = $Ny; # Outputs
structure(5) = 0; # Zero outputs
structure(6) = $Nui; #Internal inputs
structure(7) = $Nuc; # Connecting inputs
makedef(structure,deffilenum); #Create definitions
EOF
## Extra bits for the ese file to define connections
for subsystem in $subsystems; do
echo Doing $subsystem
Ny=`mtt_getsize -internal $subsystem"_1" y`
Nu=`mtt_getsize -internal $subsystem"_1" u`
echo Ny $Ny Nu $Nu Nx $Nx
echo MATRIX "MTT_"$subsystem"_uc("$Nu",1);" >> $1_def.r
echo %Subsystem input connections for $subsystem >> $1_ese.r
octave -q <<EOF >> $1_ese.r
for i=1:$Nu
printf("MTT_%s_uc(%i,1) := %s_1_MTTu%i;\n", "$subsystem", i, "$subsystem", i);
endfor;
EOF
done
fi
echo "END;" >> $1_ese.r
echo "END;" >> $1_def.r
# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile
# Now invoke the standard error handling.
mtt_error mtt_error.txt
|