#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
## $Id$
# Copyright (C) 1999,2000 by Peter J. Gawthrop
# Tell user
Sys=$1
lang=$2
date=`date`
outfile=$1_input.$2
Nu=`mtt_getsize $Sys u` # Inputs
echo "Creating $outfile for standard input"
## Pascal code
make_p()
{
cat <<EOF > $outfile
PROCEDURE $1_input(VAR mttu : InputVector;
mttx : StateVector;
mtty : OutputVector;
mttt : REAL;
par : ParameterVector);
{Created by MTT on $date for standard input to simulation}
VAR t : REAL; Start:BOOLEAN;
BEGIN{$1_input}
{Zap comments}
IF (input^ = chr("#")) THEN
BEGIN
readln;
WHILE (input^ = chr("#")) DO readln;
END;
read(t); { Read, and discard, first column (time) }
FOR mtti:=1 TO $Nu DO {Read the inputs}
read(mttu[mtti]);
readln; {Next line}
END{$1_input};
EOF
}
make_m() {
mtt_header $Sys input m stdin > $outfile
cat >> $outfile <<EOF
## The "standard input"
global MTT_input MTT_input_index MTT_input_last
MTT_input_index = min(++MTT_input_index,MTT_input_last);
mttu = MTT_input(MTT_input_index,:);
## END Code
endfunction
EOF
}
make_cc() {
cat > $outfile <<EOF
#include "${Sys}_def.h"
DEFUN_DLD (sidRC_input, args, ,
"Usage: [mttu] = sidRC_input(mttx,mtty,mttt,mttpar)
Octave input representation of system sidRC");
{
static ColumnVector u (MTTNU);
static Matrix mtt_input;
octave_value_list retval;
mtt_input = octave_value (get_global_value ("MTT_input"));
retval (0) = octave_value (mtt_input);
return (retval);
}
EOF
}
case $lang in
p)
make_p
;;
m)
make_m
;;
cc)
make_cc
;;
*)
echo language $lang not supported - sorry
esac