Overview
Comment:Added logic rep
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: f8ae8dbdd327cbd0cf7fa48f3d0375d21b162136dd8cb78f097f2508121d1e8c
User & Date: gawthrop@users.sourceforge.net on 2000-10-17 09:55:21
Other Links: branch diff | manifest | tags
Context
2000-10-17
09:55:55
Now writes to standard output
Write the name, not the array
check-in: b836715b25 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
09:55:21
Added logic rep check-in: f8ae8dbdd3 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
09:55:00
Replaced switchopen by logic check-in: d6be3bf0b4 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_txt2m from [1ec24a214e] to [05d7cf5e5b].

11
12
13
14
15
16
17



18
19
20
21
22
23
24


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$



# %% Revision 1.9  2000/10/13 11:07:33  peterg
# %% Started conversion to new style state, input ext
# %%
# %% Revision 1.8  2000/09/30 13:53:07  peterg
# %% Default to empty matix in numpar.m -- avoids probs for parameter-free systems
# %%
# %% Revision 1.7  2000/05/19 17:46:17  peterg







>
>
>







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


# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% Version control history
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %% $Id$
# %% $Log$
# %% Revision 1.10  2000/10/15 09:51:50  peterg
# %% Set array code in input rep
# %%
# %% Revision 1.9  2000/10/13 11:07:33  peterg
# %% Started conversion to new style state, input ext
# %%
# %% Revision 1.8  2000/09/30 13:53:07  peterg
# %% Default to empty matix in numpar.m -- avoids probs for parameter-free systems
# %%
# %% Revision 1.7  2000/05/19 17:46:17  peterg
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
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

system=$1
representation=$2
outfile=$1_$2.m

# Inform user
echo Creating $1_$2.m

#Create the rep  file complete with headers.
case $representation in
    simpar)

       arraycode=no



      ;;
    numpar)
       name=mttpar
       arraycode=yes


      ;;
    state)
      name=mttx
      arraycode=yes
      ;;
    input)
      name=mttu
      arraycode=yes
      ;;
    *)
      echo Representation $representation not supported
      exit
      #echo "function $name = $1_$2$arg" > $outfile
      #echo "%% $2 file ($1_$2.m)" >> $outfile
      #echo "%% Generated by MTT at `date`" >> $outfile
      #echo "% Global variable list" >>  $outfile
      #sympar2global_txt2m $1 >> $outfile
      ;;
esac

# Generate the header
mtt_header $system $representation m  > $outfile











# Write out the code from the txt file


cat  $1_$2.txt | strip_comments | grep -v METHOD |\
awk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");







|



|
>
|
>
>
>



|
>
>



|
<
<
<
<















>
>
>
>
>
>
>
>
>
>

>
>







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
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

system=$1
representation=$2
outfile=$1_$2.m

# Inform user
echo Creating $outfile

#Create the rep  file complete with headers.
case $representation in
    input)
      name=mttu
      arraycode=$representation
      ;;
    logic)
      name=mttx
      ;;
    numpar)
       name=mttpar
      arraycode=$representation
      ;;
    simpar)
      ;;
    state)
      name=mttx
      arraycode=$representation




      ;;
    *)
      echo Representation $representation not supported
      exit
      #echo "function $name = $1_$2$arg" > $outfile
      #echo "%% $2 file ($1_$2.m)" >> $outfile
      #echo "%% Generated by MTT at `date`" >> $outfile
      #echo "% Global variable list" >>  $outfile
      #sympar2global_txt2m $1 >> $outfile
      ;;
esac

# Generate the header
mtt_header $system $representation m  > $outfile

## Special for logic rep
if [ "$representation" = "logic" ]; then
  echo >> $outfile
  echo "## Inputs" >> $outfile
  mtt_name2array $system input >> $outfile # Set up input by name
  echo >> $outfile
  echo "## States" >>$outfile
  mtt_name2array $system state >> $outfile # Set up state by name
fi

# Write out the code from the txt file
echo >> $outfile
echo "## User defined code from $1_$2.txt" >> $outfile
cat  $1_$2.txt | strip_comments | grep -v METHOD |\
awk -F#  'BEGIN{
quote = "\047";
doublequote = "\042";
}
{
  N=split($1,a,"=");
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208







209
210
211
212
213





     -e 's/\[\([0-9]*\)\]/(\1)/g' \
     -e 's/\([^a-zA-Z_]\)t\([^a-zA-Z_]\)/\1mttt\2/g' \
     -e 's/x(/mttx(/g' \
     -e 's/u(/mttu(/g' \
     -e 's/mttmtt/mtt/g' \
 >> $outfile

if [ "$arraycode" = "yes" ]; then
  new_style=`strip_comments < $1_$2.txt| grep "$name(">/dev/null; echo $?`

  if [ "$new_style" = "1" ]; then
    echo >> $outfile
    echo "  ## Set up the $name vector"  >> $outfile
    echo "  $name = []; # Default to empty matrix (Remove in mtt_m2p)"  >> $outfile
    mtt_name2array $1 $2 set   >> $outfile
  else
    echo "Old-style file detected: not creating array translations"  
  fi
fi








# End of the function
echo '## END Code' >> $outfile
echo 'endfunction' >> $outfile













|






|




>
>
>
>
>
>
>





>
>
>
>
>
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
     -e 's/\[\([0-9]*\)\]/(\1)/g' \
     -e 's/\([^a-zA-Z_]\)t\([^a-zA-Z_]\)/\1mttt\2/g' \
     -e 's/x(/mttx(/g' \
     -e 's/u(/mttu(/g' \
     -e 's/mttmtt/mtt/g' \
 >> $outfile

if [ -n "$arraycode" ]; then
  new_style=`strip_comments < $1_$2.txt| grep "$name(">/dev/null; echo $?`

  if [ "$new_style" = "1" ]; then
    echo >> $outfile
    echo "  ## Set up the $name vector"  >> $outfile
    echo "  $name = []; # Default to empty matrix (Remove in mtt_m2p)"  >> $outfile
    mtt_name2array $1 $arraycode set   >> $outfile
  else
    echo "Old-style file detected: not creating array translations"  
  fi
fi

## Special for logic rep
if [ "$representation" = "logic" ]; then
  echo >> $outfile
  echo "## Open switches" >> $outfile
  switch_txt2m Bounce >> $outfile
fi

# End of the function
echo '## END Code' >> $outfile
echo 'endfunction' >> $outfile







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