Differences From Artifact [82311a7db2]:

To Artifact [5aa349fe2c]:


11
12
13
14
15
16
17



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







+
+
+







# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.67  2002/04/18 17:02:15  gawthrop
## foo=zeros(3,1) translated as zero_state(foo,3)
##
## Revision 1.66  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
## Revision 1.65  2001/02/09 02:56:46  geraint
## Translate some binary operators
## Allows use of ! in logic.txt
##
223
224
225
226
227
228
229
230
231
232



233
234
235
236
237
238
239
226
227
228
229
230
231
232



233
234
235
236
237
238
239
240
241
242







-
-
-
+
+
+







##
###############################################################



# Set up variables
args=`echo $1 | sed 's/_/ /' | sed 's/\./ /'`
Sys=`echo $args  | awk '{print $1}'`
sys=`echo $Sys  | awk '{print tolower($1)}'`
rep=`echo $args  | awk '{print $2}'`
Sys=`echo $args  | gawk '{print $1}'`
sys=`echo $Sys  | gawk '{print tolower($1)}'`
rep=`echo $args  | gawk '{print $2}'`
Sys_rep="$Sys""_""$rep"
Sys_smx="$Sys""_smx"
Sys_smxp="$Sys""_smx.p"
Filename="$Sys""_""$rep.p"
filename="$sys""_""$rep.p"

Method=$2; # The integration method
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
254
255
256
257
258
259
260

261
262
263
264
265
266
267
268







-
+







  echo Creating $Filename $MethodBlurb $StdinBlurb 

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nxx=`mtt_getsize $Sys xx` # States x States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 
Npar=`wc -l $Sys\_sympar.txt | awk '{print $1}'`
Npar=`wc -l $Sys\_sympar.txt | gawk '{print $1}'`


#if [ "$rep" = "simpar" ]; then
#    mtt -q $Sys smx p
#fi

# Heading
377
378
379
380
381
382
383
384

385
386
387
388
389
390
391
380
381
382
383
384
385
386

387
388
389
390
391
392
393
394







-
+







	echo "    AA,mtte                     : StateMatrix;"
	echo "    MTTi,MTTj,it,iLast: INTEGER;"
	##echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	## echo "    mttMETHOD : IntegrationMethod;"
	echo "    open_switches  : StateVector;"
	echo "    numparfile, statefile, simparfile  : TEXT;"
        strip_comments <${Sys}_switch.txt |\
          awk '{printf("%s_logic : REAL;\n", tolower($1))}' 
          gawk '{printf("%s_logic : REAL;\n", tolower($1))}' 
	echo ""
        mtt_txt2declare $Sys sympar p
        mtt_txt2declare $Sys struc p
        ;;
#    switchopen)
#	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
#	echo "VAR"
432
433
434
435
436
437
438
439

440
441
442
443
444
445
446
447
448
449
450

451
452
453
454
455
456
457
435
436
437
438
439
440
441

442
443
444
445
446
447
448
449
450
451
452

453
454
455
456
457
458
459
460







-
+










-
+








cat $Sys_rep.m |\
grep -v 'Remove in mtt_m2p'  |\
grep -v '^[ ]*function'  |\
grep -v '^[ ]*endfunction'  |\
grep -v 'MTT_data'  |\
sed "s/^$space%/#/" | sed "s/\([;)]$space\)%/\1#/" |\
awk -F# '{printf("%s",$1) 
gawk -F# '{printf("%s",$1) 
          if (NF>1) printf("{* %s *}", $2)
          printf("\n") 
         }' |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)/\2(\1)/" |\
sed "s/$space\($non_space\)$spaces=${spaces}zeros(\([0-9]*\),1)/zero_state(\1,\2)/" |\
sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\
sed "s/,)/)/" |\
fix_operators |\
awk '
gawk '
function printvar(Name,N) {
  if (N<1) return;
  width = 10;
  kk = 0; 
  for (k=1;k<=N;k++) {
    printf("mtt%s%i", Name, k);
    if (k==N)

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