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
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
|
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
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
243
244
245
246
247
248
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
end;
else # Now do SS which are not ports
% Effort
if strcmp(effort_attribute, "external")
if bonds(1,1)==-1 % Source
inputs = inputs+1;
fprintf(filenum, "%s := MTTu(%d,1);\n", ...
varname(name, bond_number,1),inputs);
varname(sname, bond_number,1),inputs);
else % Sensor
outputs = outputs+1;
fprintf(filenum, "MTTy(%d,1) := %s;\n", ...
outputs, varname(name, bond_number,1));
outputs, varname(sname, bond_number,1));
end;
elseif strcmp(effort_attribute, "unknown") % Unknown input
unknown_inputs = unknown_inputs + 1;
fprintf(filenum, "%s := MTTUi%d;\n", ...
varname(name, bond_number,1), unknown_inputs);
varname(sname, bond_number,1), unknown_inputs);
elseif strcmp(effort_attribute, "internal")
% Do nothing
else
if bonds(1,1)==-1 % Named or unknown source
fprintf(filenum, "%s := %s;\n", ...
varname(name, bond_number,1), effort_attribute);
varname(sname, bond_number,1), effort_attribute);
else % Sensor
if strcmp(effort_attribute, "zero") %Zero output
zero_outputs = zero_outputs + 1;
fprintf(filenum, "MTTyz%d := %s;\n", ...
zero_outputs, varname(name, bond_number,1));
zero_outputs, varname(sname, bond_number,1));
else
mtt_error([effort_attribute, " not appropriate for an output "]);
end;
end;
end;
% Flow
if strcmp(flow_attribute, "external")
if bonds(1,2)==1 % Source
inputs = inputs+1;
fprintf(filenum, "%s := MTTu(%d,1);\n", varname(name, bond_number,-1),inputs);
fprintf(filenum, "%s := MTTu(%d,1);\n", varname(sname, bond_number,-1),inputs);
else % Sensor
outputs = outputs+1;
fprintf(filenum, "MTTy(%d,1) := %s;\n", outputs, ...
varname(name, bond_number,-1));
varname(sname, bond_number,-1));
end;
elseif strcmp(flow_attribute, "unknown") % Unknown input
unknown_inputs = unknown_inputs + 1;
fprintf(filenum, "%s := MTTUi%d;\n", ...
varname(name, bond_number,-1), unknown_inputs);
varname(sname, bond_number,-1), unknown_inputs);
elseif strcmp(flow_attribute, "internal")
% Do nothing
else % Named constant
if bonds(1,2)==1 % Source
fprintf(filenum, "%s := %s;\n", ...
varname(name, bond_number,-1), flow_attribute);
varname(sname, bond_number,-1), flow_attribute);
else % Sensor
if strcmp(flow_attribute, "zero") %Zero output
zero_outputs = zero_outputs + 1;
fprintf(filenum, "MTTyz%d := %s;\n", ...
zero_outputs, varname(name, bond_number,-1));
zero_outputs, varname(sname, bond_number,-1));
else
mtt_error([flow_attribute, " not appropriate for an output "]);
end;
end;
end;
end;
structure(3) = inputs;
structure(4) = outputs;
structure(5) = zero_outputs;
structure(6) = unknown_inputs;
end;
|