Differences From Artifact [1316a2f255]:

To Artifact [1010bde4b7]:


15
16
17
18
19
20
21



22
23
24
25
26
27
28
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31







+
+
+







# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.12  1996/08/15 16:47:47  peter
## DAE solution (experimental) included.
##
## Revision 1.11  1996/08/15 11:55:30  peter
## Checks for changed argument.
## Handles frequency response.
##
## Revision 1.10  1996/08/15 07:44:24  peter
## Now handles generic transformations using %.
##
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
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
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
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
209
210
211
212
213
214
215







-
+





+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








+
+
+









-
+










-
+









-
+

+



+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
+
+







fi

# Save up the argument list in a file; but only if argument has changed
ARGS=$4;
cat > $1_args.new <<EOF
$ARGS
EOF
touch $1_args.m

DIFF=$(diff -bq $1_args.m $1_args.new)

if [ -n "$DIFF" ]; then
  mv $1_args.new $1_args.m
fi

# Classify the representation - needed for conversion route to postscript
case $2 in
	abg )
		REPTYPE='bg' ;;
	cbg )
		REPTYPE='bg' ;;
	odesol)
		REPTYPE='data' ;;
	daesol)
		REPTYPE='data' ;;
	sr)
		REPTYPE='data' ;;
	lmfr)
		REPTYPE='data' ;;
	lpfr)
		REPTYPE='data' ;;
	nyfr)
		REPTYPE='data' ;;
	nifr)
		REPTYPE='data' ;;
	*)
		REPTYPE='tex' ;;
esac

# This is the main mtt programme
 
make -s  -f -  $1_$2.$3 << EOF

# Cancel implicit rules I don't want
%.dvi: %.tex

# Create an arg file if it doesn't exist
$1_args.m:
	touch $1_args.m

#Create acausal bond graph figure using xfig 
$1_abg.fig:
	$FIG $1_abg.fig 

#Create empty files (with titles) if not already there
$1_lbl.txt:
	echo Creating $1_lbl.txt
	( \
	echo "%% Label file ($1_lbl.txt)"; \
	echo "%% Label file for $1 ($1_lbl.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"; \
        )> $1_lbl.txt
$1_cr.r:
	makecr $1
$1_sympar.r:
	echo Creating $1_sympar.r
	( \
	echo "%% Symbolic parameter file ($1_sympar.r)"; \
	echo "%% Symbolic parameter file for $1 ($1_sympar.r)"; \
	echo "%% Change the following line to reflect the number of variables"; \
	echo "MTTNVar := 0;"; \
	echo "IF MTTNVar>0 THEN MATRIX MTTVar(MTTNVar,1);"; \
 	echo "%% Add an assignment statement here for each variable"; \
 	echo "%% For example: MTTVar(1,1) := r"; \
        )> $1_sympar.r
$1_simp.r:
	echo Creating $1_simp.r
	( \
	echo "%% Reduce comands to simplify output ($1_simp.r)"; \
	echo "%% Reduce comands to simplify output for $1 ($1_simp.r)"; \
        )> $1_simp.r

$1_numpar.m: $1_sympar.r
	mknumpar $1; matlab_tidy $1_numpar.m;

$1_input.m:
	echo Creating $1_input.m
	( \
	echo "function u = $1_input(t)"; \
	echo "%% Input file for $1 ($1_input.m)"; \
	echo "%% This file provides the system input for simulation:";\
	echo; \
	echo "% Set up system definitions"; \
	echo "[nx,ny,nu,nz,nyz] = $1_def;"; \
	echo "% Change the following lines as you wish"; \
	echo "u = zeros(nu,1);"; \
	echo "u(1) = 1;"; \
        )> $1_input.m

$1_sspar.r:
	echo Creating $1_sspar.r
	echo "%% Reduce steady-state parameter file ($1_sspar.r)" > $1_sspar.r
	echo "%% Reduce steady-state parameter file for $1 ($1_sspar.r)" \
	> $1_sspar.r

#Raw bond graph: fig file to mfile
$1_rbg.m: $1_abg.fig $1_lbl.txt
	rbg_fig2m $1

$1_cmp.m: $1_rbg.m

274
275
276
277
278
279
280
281

282
283

284
285
286
287
288
289
290
320
321
322
323
324
325
326

327
328

329
330
331
332
333
334
335
336







-
+

-
+







$1_tf.tex: $1_def.r $1_tf.r $1_sympar.r $1_simp.r
	tf_r2tex $1; latex_tidy $1_tf.tex


#Time responses
$1_sr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m
	dm2sr_m $1 '$ARGS'
$1_odesol.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m
$1_odesol.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m
	ode2odesol_m $1 '$ARGS'
$1_daesol.m: $1_dae.m $1_numpar.m $1_args.m $1_def.m
$1_daesol.m: $1_dae.m $1_numpar.m $1_args.m $1_def.m $1_input.m
	dae2daesol_m $1 '$ARGS'

#Frequency responses
$1_fr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m
	dm2fr_m $1 '$ARGS'
$1_lmfr.m: $1_fr.m
	touch $1_lmfr.m
315
316
317
318
319
320
321

322

323
324
325

326

327
328

329

330

331
332

333
334

335
336
337
338
339
340
341
342

343
344
345
346
347
348
349
361
362
363
364
365
366
367
368

369
370
371

372
373
374
375

376
377
378
379
380
381

382
383
384
385
386
387
388
389
390
391
392

393
394
395
396
397
398
399
400







+
-
+


-
+

+

-
+

+

+

-
+


+







-
+








#Generic conversion of LaTeX doc to dvi
$1_$2.dvi: $1_$2.doc
	echo Creating $1_$2.dvi
	latex $1_$2.doc > /dev/null

#Create PostScript version of fig files
ifeq ($REPTYPE,bg)
%.ps : %.fig
$1_$2.ps : $1_$2.fig
	echo Creating $1_$2.ps
	fig2dev -Lps $1_$2.fig >$1_$2.ps

endif

ifeq ($REPTYPE,data)
#Create PostScript version of dat file
%.ps: %.gdat
$1_$2.ps: $1_$2.gdat
	gdat2ps $1_$2 '$ARGS'
endif

ifeq ($REPTYPE,tex)
#Create PostScript version of dvi file
%.ps: %.dvi
$1_$2.ps: $1_$2.dvi
	echo Creating $1_$2.ps
	dvips -o $1_$2.ps $1_$2
endif

#View a ps file
$1_$2.view: $1_$2.ps
	echo Creating view of $1_$2
	ghostview $1_$2.ps&

#View a gdat file
#%.view: %.gdat
#$1_$2.view: $1_$2.gdat
#	echo Creating view of $1_$2
#	gdat2view $1_$2 '$ARGS'&
	

#Report generation
$1_rep.tex: $1_sum.tex $1_dae.tex $1_lbl.txt $1_sympar.r $1_cr.r \
            $1_abg.ps

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