Overview
Comment:Sorts components alphabetically (type:name) within the categories:
internal ports, components, 0 junctions and 1 junctions.

Standardising the order in which components are listed allows models
built with different editors to interact correctly by separating the
graphical information from the data which is required to build models.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: d1cc72a673c80e3b4b2cde27db2adb8c109981e30eb06368767cd8c6eb21577a
User & Date: geraint@users.sourceforge.net on 2004-08-04 19:46:42
Other Links: branch diff | manifest | tags
Context
2004-08-04
19:51:14
Specifies maintainers address. check-in: 00cb23ca74 user: geraint@users.sourceforge.net tags: origin/master, trunk
19:46:42
Sorts components alphabetically (type:name) within the categories:
internal ports, components, 0 junctions and 1 junctions.

Standardising the order in which components are listed allows models
built with different editors to interact correctly by separating the
graphical information from the data which is required to build models. check-in: d1cc72a673 user: geraint@users.sourceforge.net tags: origin/master, trunk

19:41:47
Writes 0 junctions before 1 junctions. check-in: c7b49097a0 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/awk/rbg_fig2m.awk from [154be7af66] to [b9d77f2ccd].

8
9
10
11
12
13
14



15
16
17
18
19
20
21
# Copyright (c) P.J.Gawthrop, 1996.

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



## Revision 1.44  2002/05/25 09:23:47  gawthrop
## Self-naming components: name is mttTYPE or mttTYPE_2 ...
##
## Revision 1.43  2002/05/22 10:33:18  gawthrop
## Nameless components are now named according to type - replaces old
## mtt1 etc style.
##







>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.45  2004/04/07 12:17:43  gawthrop
## Handles new Fig header line.
##
## Revision 1.44  2002/05/25 09:23:47  gawthrop
## Self-naming components: name is mttTYPE or mttTYPE_2 ...
##
## Revision 1.43  2002/05/22 10:33:18  gawthrop
## Nameless components are now named according to type - replaces old
## mtt1 etc style.
##
218
219
220
221
222
223
224

225





226
227
228
229
230
231
232
#		field  3 is the CR arguments
#  	The fig file represents components by 14 fields
#             field 1 = 4
#		fields 12 and 13 are the coordinates
#		field 14 is the type:name string terminated by \001
# To prevent text being confused with components, components consist
# of alphanumeric characters and : and _ only.

# The lbl file is used to sort the components.





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

function modulo10(x) {
  return x-int(x/10)*10
    }

function exact_match(name1, name2) {







>
|
>
>
>
>
>







221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#		field  3 is the CR arguments
#  	The fig file represents components by 14 fields
#             field 1 = 4
#		fields 12 and 13 are the coordinates
#		field 14 is the type:name string terminated by \001
# To prevent text being confused with components, components consist
# of alphanumeric characters and : and _ only.
# 
# Components are sorted alphabetically ("type:name")
# within the following categories:
# 1) internal ports (SS:[...])
# 2) basic components, subsystems and external ports 
# 3) 0 junctions
# 4) 1 junctions
##############################################################

function modulo10(x) {
  return x-int(x/10)*10
    }

function exact_match(name1, name2) {
266
267
268
269
270
271
272




















273
274
275
276
277
278
279
      args = $3;

      label[i_label,1] = name; 
      label[i_label,2] = CR;
      label[i_label,3] = args;
	}
}





















function fig_info() {
# Grabs the fig-file information for a component
  return(sprintf("%s %s %s %s %s %s %s %s %s %s %s ", \
		 $1, $2, $3, $4, $5, $6, $7, \
		 $8, $9, $10, $11))
	 }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
      args = $3;

      label[i_label,1] = name; 
      label[i_label,2] = CR;
      label[i_label,3] = args;
	}
}

function sort_cmp() {
# Sorts components alphabetically by type then name
  for (i = 1; i <= i_label; i++) {
    name = label[i,1];
    type = comp_type[name];
    cmp_list[i] = sprintf ("'%s:%s'", type, name);
  }
  asort (cmp_list);
  for (i = 1; i <= i_label; i++) {
    for (j = 1; j <= i_label; j++) {
      name = label[j,1];
      type = comp_type[name];
      typename = sprintf ("'%s:%s'", type, name);
      if (typename == cmp_list[i]) {
	sort_cmp_list[i] = j;
      }
    }
  }
}

function fig_info() {
# Grabs the fig-file information for a component
  return(sprintf("%s %s %s %s %s %s %s %s %s %s %s ", \
		 $1, $2, $3, $4, $5, $6, $7, \
		 $8, $9, $10, $11))
	 }
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316

# It is terminated by \001 - so delete this termination
  str = substr(str,1,length(str)-4);

# Zap maths
  ##gsub(/[()-+*/]/,"",str); 

# Loose the cr stuff (if present)
  if (depth==0) {
      N=split(str,a,delimiter);
      if (N==3)
	  str=sprintf("%s%s%s", a[1],delimiter,a[2]);
    }

# A component string contains only alphanumeric  _ and :







|







331
332
333
334
335
336
337
338
339
340
341
342
343
344
345

# It is terminated by \001 - so delete this termination
  str = substr(str,1,length(str)-4);

# Zap maths
  ##gsub(/[()-+*/]/,"",str); 

# Lose the cr stuff (if present)
  if (depth==0) {
      N=split(str,a,delimiter);
      if (N==3)
	  str=sprintf("%s%s%s", a[1],delimiter,a[2]);
    }

# A component string contains only alphanumeric  _ and :
733
734
735
736
737
738
739

740
741
742

743
744
745
746
747
748
749

750
751


752
753

















754
755
756
757
758
759
760
761
762
  for (i = 1; i <= i_stroke; i++)
    print  strokes[i] >> b_file;
  printf("];\n") >> b_file;

  printf("rcomponents = [") >> b_file;
  j = 0;



# Do the port components, in order of appearance, first.
  for (i = 1; i <= i_label; i++) {

    name = label[i,1];
    if (match(name,port_regexp))
      write_component(i);
  }

# Now do the ordinary components, in order of appearance, last.
  for (i = 1; i <= i_label; i++) {

    name = label[i,1];
    if (!match(name,port_regexp))


      write_component(i);  
}

















  printf("];\n") >> b_file;

# Print the (internal) ports list
  printf("port_coord = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    printf("%s %s\n", a[1], a[2]) >> b_file;
  }
  printf("];\n\n") >> b_file;







>



>
|

|

|
|

>
|

>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|







762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
  for (i = 1; i <= i_stroke; i++)
    print  strokes[i] >> b_file;
  printf("];\n") >> b_file;

  printf("rcomponents = [") >> b_file;
  j = 0;

  sort_cmp();	# sort components alphabetically

# Do the port components, in order of appearance, first.
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (match(name,port_regexp))
      write_component(num);
  }
  
# then do the ordinary components, in order of appearance.
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if ((!match(comp_type[name],"0"))&&
	  (!match(comp_type[name],"1"))) 
	write_component(num);
  }
  
# followed by the 0 junctions
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if (match(comp_type[name],"0"))
	write_component(num);
  }
# and finally the 1 junctions
  for (i = 1; i <= i_label; i++) {
    num  = sort_cmp_list[i];
    name = label[num,1];
    if (!match(name,port_regexp))
      if (match(comp_type[name],"1"))
	write_component(num);      
  }
  printf("];\n") >> b_file;
  
# Print the (internal) ports list
  printf("port_coord = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    printf("%s %s\n", a[1], a[2]) >> b_file;
  }
  printf("];\n\n") >> b_file;


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