Overview
Comment:Fixed overwriting of ports.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 731218f1f6110a5ea983ba81e03565dcd7c8ba91c4819e0ea48a2cdf26093f34
User & Date: gawthrop@users.sourceforge.net on 2000-09-14 12:07:15
Other Links: branch diff | manifest | tags
Context
2000-09-14
12:40:45
Now works out the level correctely check-in: dd1498363a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:07:15
Fixed overwriting of ports. check-in: 731218f1f6 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:04:48
New 2 parameter version check-in: 6c323ae3f5 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/cbg2fig.m from [3db2dd64e3] to [0b169241cf].

1
2
3
4
5
6
7
8
9
function cbg2fig(system_name, ...
                 system_type, full_name, ...
                 stroke_length, stroke_thickness, stroke_colour, ...
                 comp_font, comp_colour_u, comp_colour_o)

  ## cbg2fig - converts causal bg to figure
  ##
  ##     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% Model
  ##     Transformation Tools %%%%%
|
<







1

2
3
4
5
6
7
8
function cbg2fig(system_name, system_type, full_name, ...

                 stroke_length, stroke_thickness, stroke_colour, ...
                 comp_font, comp_colour_u, comp_colour_o)

  ## cbg2fig - converts causal bg to figure
  ##
  ##     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% Model
  ##     Transformation Tools %%%%%
20
21
22
23
24
25
26




27
28
29
30
31
32
33
  ## Copyright (c) P.J.Gawthrop, 1996.

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




  ## %% Revision 1.12  2000/09/14 08:07:00  peterg
  ## %% Reformated as an Octave function
  ## %%
  ## %% Revision 1.11  2000/01/18 14:52:02  peterg
  ## %% Removed recursion --- maybe put back via a flag later
  ## %%
  ## %% Revision 1.10  1998/12/14 15:27:32  peterg







>
>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  ## Copyright (c) P.J.Gawthrop, 1996.

  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% Version control history
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% $Id$
  ## %% $Log$
  ## %% Revision 1.13  2000/09/14 09:12:19  peterg
  ## %% Fixed stroke orientation bug with bent bonds
  ## %% Uses new info from the _rbg.m file - 4 new cols in rbonds
  ## %%
  ## %% Revision 1.12  2000/09/14 08:07:00  peterg
  ## %% Reformated as an Octave function
  ## %%
  ## %% Revision 1.11  2000/01/18 14:52:02  peterg
  ## %% Removed recursion --- maybe put back via a flag later
  ## %%
  ## %% Revision 1.10  1998/12/14 15:27:32  peterg
96
97
98
99
100
101
102
103
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

  ## Create a back slash '\' character.
  bs = setstr(92);

  ## Create the (full) system name
  if strcmp(full_name,'')
    full_name = system_name;
    system_type = system_name;
  else
    full_name = [full_name, '_', system_name];
  end;

  full_name_type = [full_name, '_', system_type];
  ## $$$ fig_name = [full_name_type, '_cbg.fig'];
  fig_name = [full_name, '_cbg.fig']
  
  ## Return if initial fig file doesn't exist
  if exist(fig_name)~=2
    return
  end;

  ## Setup file - append to the fig file
  filenum = fopen(fig_name, 'a');

  ## Get the raw and the processed bonds
  eval(['[rbonds,rstrokes,rcomponents] = ', system_type, '_rbg;']);
  %eval(['[bonds,components,n_ports] = ', system_type, '_abg;']);
  eval(["ABG = ", system_type, "_abg;"]);
  bonds=ABG.bonds;

  ## Original number of bonds
  [n_bonds,junk] = size(rbonds);

  ## Get the causal bonds
  %eval(['[cbonds,status]=', full_name, '_cbg;']);
  eval(["CBG = ", full_name, "_cbg;"]);
  cbonds=CBG.bonds;

  ## Check sizes
  [Rows,Columns] = size(rcomponents);
  if (Columns ~= 13)
    error('Incorrect rcomponents matrix: must have 13 columns');







<


















<







|







99
100
101
102
103
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

  ## Create a back slash '\' character.
  bs = setstr(92);

  ## Create the (full) system name
  if strcmp(full_name,'')
    full_name = system_name;

  else
    full_name = [full_name, '_', system_name];
  end;

  full_name_type = [full_name, '_', system_type];
  ## $$$ fig_name = [full_name_type, '_cbg.fig'];
  fig_name = [full_name, '_cbg.fig']
  
  ## Return if initial fig file doesn't exist
  if exist(fig_name)~=2
    return
  end;

  ## Setup file - append to the fig file
  filenum = fopen(fig_name, 'a');

  ## Get the raw and the processed bonds
  eval(['[rbonds,rstrokes,rcomponents] = ', system_type, '_rbg;']);

  eval(["ABG = ", system_type, "_abg;"]);
  bonds=ABG.bonds;

  ## Original number of bonds
  [n_bonds,junk] = size(rbonds);

  ## Get the causal bonds
  #eval(['[cbonds,status]=', full_name, '_cbg;']);
  eval(["CBG = ", full_name, "_cbg;"]);
  cbonds=CBG.bonds;

  ## Check sizes
  [Rows,Columns] = size(rcomponents);
  if (Columns ~= 13)
    error('Incorrect rcomponents matrix: must have 13 columns');
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


  ## Get indices of bonds with changed causality -- but ignore the extra bonds
  ## due to vector bond expansion
  changed_e = bonds(1:n_bonds,1)~=cbonds(1:n_bonds,1);
  changed_f = bonds(1:n_bonds,2)~=cbonds(1:n_bonds,2);
  changed = changed_e|changed_f;
  ## Don't do port bonds
				#if n_ports>0
				#  port_bonds = sort(abs(components(1:n_ports,1)));
				#  changed(port_bonds) = zeros(n_ports,1);
				#  changed_e(port_bonds) = zeros(n_ports,1);
				#  changed_f(port_bonds) = zeros(n_ports,1);
				#end

  index_e  = getindex(changed_e,1)'
  index_f  = getindex(changed_f,1)'
  index_ef  = getindex(changed,1)';

  ## Print the new strokes in fig format
  if index_ef(1,1)>0
    for i = index_e		# Do the effort stroke - opp. side to arrow

      if cbonds(i,1)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;







<
<
<
<
<
<
<

|
|





<







173
174
175
176
177
178
179







180
181
182
183
184
185
186
187

188
189
190
191
192
193
194


  ## Get indices of bonds with changed causality -- but ignore the extra bonds
  ## due to vector bond expansion
  changed_e = bonds(1:n_bonds,1)~=cbonds(1:n_bonds,1);
  changed_f = bonds(1:n_bonds,2)~=cbonds(1:n_bonds,2);
  changed = changed_e|changed_f;








  index_e  = getindex(changed_e,1)';
  index_f  = getindex(changed_f,1)';
  index_ef  = getindex(changed,1)';

  ## Print the new strokes in fig format
  if index_ef(1,1)>0
    for i = index_e		# Do the effort stroke - opp. side to arrow

      if cbonds(i,1)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;

    for i = index_f		# Do the flow stroke - same side as arrow

      if cbonds(i,2)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;







<







208
209
210
211
212
213
214

215
216
217
218
219
220
221

      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;

    for i = index_f		# Do the flow stroke - same side as arrow

      if cbonds(i,2)==1		# Stroke at arrow end
	bond_vector = arrow_end_direction(i,:); # Directional vector
	stroke_end_1 = arrow_end(i,:);
      else
	bond_vector = other_end_direction(i,:); # Directional vector
	stroke_end_1 = other_end(i,:);
      end;
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;
  end;

  ## Print all the components - coloured acording to causality.
  for i = 1:N_ports+N_components
    if i>N_ports			# Subsystem
      comp_name = CBG.subsystemlist(i-N_ports,:);
      eval(["comp_status = CBG.subsystems.", comp_name, ".status;"]);
    else
      comp_name = CBG.portlist(i,:);
      eval(["comp_status = CBG.ports.", comp_name, ".status;"]);
    end







|







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
      fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	      stroke_end_1(1), stroke_end_1(2), ...
	      stroke_end_2(1), stroke_end_2(2) );
    end;
  end;

  ## Print all the components - coloured acording to causality.
  for i = 1+N_ports:N_ports+N_components
    if i>N_ports			# Subsystem
      comp_name = CBG.subsystemlist(i-N_ports,:);
      eval(["comp_status = CBG.subsystems.", comp_name, ".status;"]);
    else
      comp_name = CBG.portlist(i,:);
      eval(["comp_status = CBG.ports.", comp_name, ".status;"]);
    end
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286

287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
    if comp_status==1		# Then over causal
      fig_params(3) = comp_colour_o;
      fig_params(6) = comp_font;
    end;


    ## Now print the component in fig format
    eval(['[comp_type,comp_name] = ', system_type, '_cmp(i)']);
    
    if index(comp_name,"mtt")==1 # Its a dummy name
      typename = comp_type;	# just show type
    else
      typename = [comp_type,":",comp_name];
    endif;

    Terminator = [bs, '001'];   
    for j = 1:length(fig_params)
      fprintf(filenum, '%1.0f ', fig_params(j));
    end;

    

    fprintf(filenum, '%1.0f %1.0f ', coords(1), coords(2)); 
    fprintf(filenum, '%s%s\n', typename, Terminator);
    
				#   % If it's a subsystem (ie not a component), do the fig file for that as
				#   % well
				#   if comp_type=='0'
				#     comp_type='zero';
				#   endif
    
				#   if comp_type=='1'
				#     comp_type='one';
				#   endif
    
    
				#   if (exist([comp_type,'_cause'])==0)
				#     cbg2fig(comp_name, ...
				# 	comp_type, full_name, ...
				#         stroke_length, stroke_thickness, stroke_colour, ...
				#         comp_font, comp_colour_u, comp_colour_o);
				#   endif

  endfor

  ## Close the file
  fclose(filenum);
  return

endfunction







|










|
>




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283


















284
285
286
287
288
289
290
291
    if comp_status==1		# Then over causal
      fig_params(3) = comp_colour_o;
      fig_params(6) = comp_font;
    end;


    ## Now print the component in fig format
    eval(['[comp_type,comp_name] = ', system_type, '_cmp(i);']);
    
    if index(comp_name,"mtt")==1 # Its a dummy name
      typename = comp_type;	# just show type
    else
      typename = [comp_type,":",comp_name];
    endif;

    Terminator = [bs, '001'];   
    for j = 1:length(fig_params)
      fprintf(filenum, '%1.0f ', fig_params(j));
    endfor
    
    

    fprintf(filenum, '%1.0f %1.0f ', coords(1), coords(2)); 
    fprintf(filenum, '%s%s\n', typename, Terminator);



















  endfor

  ## Close the file
  fclose(filenum);
  return

endfunction


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