Overview
Comment:Sorts by type:name within categories: ports, components, 0, 1
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 5e3a150ae1a15ac7ebbb63d0e67489cf6f55308e542607be26b9aa432269c33b
User & Date: geraint@users.sourceforge.net on 2004-08-05 09:07:51
Other Links: branch diff | manifest | tags
Context
2004-08-09
14:44:41
Compatible with Octave 2.1.57 check-in: d2263a7136 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2004-08-05
09:07:51
Sorts by type:name within categories: ports, components, 0, 1 check-in: 5e3a150ae1 user: geraint@users.sourceforge.net tags: origin/master, trunk
01:42:49
Sorts components alphabetically within categories: internal ports, components, 0, 1. check-in: a887e74441 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/dia2abg.pl from [144666cf03] to [6be8b310ce].

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
my $dia_input_file = '';
my $dia_output_file = '';
my $label_file = '';
my $component_list_file = '';
my $debug = 0;
my $create_component_list = 0;
my $create_abg = 0;
my $create_ibg = 1;
my $abg_file = '';
my $ibg_file = '';
my $change_flow_causality = '';
my $change_effort_causality = '';
GetOptions ('diagram_name=s' => \$diagram_name,
	    'dia_input_file=s' => \$dia_input_file,
	    'dia_output_file=s' => \$dia_output_file,







|







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
my $dia_input_file = '';
my $dia_output_file = '';
my $label_file = '';
my $component_list_file = '';
my $debug = 0;
my $create_component_list = 0;
my $create_abg = 0;
my $create_ibg = 0;
my $abg_file = '';
my $ibg_file = '';
my $change_flow_causality = '';
my $change_effort_causality = '';
GetOptions ('diagram_name=s' => \$diagram_name,
	    'dia_input_file=s' => \$dia_input_file,
	    'dia_output_file=s' => \$dia_output_file,
332
333
334
335
336
337
338
339
340


341


342


343
344
345
346


347




















348
349

350
351
352
353
354
355
356
357
358
359
360





361
362
363
364
365
366
367
368
  ${diagram_name}.${subsys_or_port}.${NM}.repetitions = $rep;
  ${diagram_name}.${subsys_or_port}.${NM}.status = $stat;
  ${diagram_name}.${subsys_or_port}.${NM}.connections = [$connections];
    
EOF
}

# This sort function allows components to be sorted in same order as
# label file, and alphabetically for components not in label file.


sub by_label_file {


    my ($a_index,$b_index);



    $a_index = $component_label_data{id_to_name($a)}[0];
    $b_index = $component_label_data{id_to_name($b)}[0];
    $a_index = 1e9 unless defined($a_index);


    $b_index = 1e9 unless defined($b_index);





















    return ($a_index <=> $b_index) || ($a_index cmp $b_index);

}

sub output_abg {
    my ($cr,$rep,$stat,$NM,$type,$arg,$bond_id,$start,$end,@clist,$connections,
	$strlength,$subsys_or_port);

    print_debug("WRITING OUTPUT TO STDIO...\n");
    $stat = "-1";

    output_abg_header();
    





    foreach my $id (keys(%component_id_tag)) {
	($subsys_or_port,$_) = id_to_name($id);
	remove_brackets(); $NM = $_;

	$type = $component_id_type{$id};

	$cr = "" unless defined($cr = $component_label_data{$NM}[1]);
	$arg = "" unless defined($arg = $component_label_data{$NM}[2]);







|
|
>
>
|
>
>
|
>
>

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











>
>
>
>
>
|







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
  ${diagram_name}.${subsys_or_port}.${NM}.repetitions = $rep;
  ${diagram_name}.${subsys_or_port}.${NM}.status = $stat;
  ${diagram_name}.${subsys_or_port}.${NM}.connections = [$connections];
    
EOF
}

sub sort_components {
    my ($type1, $str1, $subsys_or_port1,
	$type2, $str2, $subsys_or_port2,
	$retval);
    
    $type1 = $component_id_type{$a};
    $type2 = $component_id_type{$b};

    $str1 = $component_id_tag{$a};
    $str2 = $component_id_tag{$b};

    ($subsys_or_port1, $_) = id_to_name($a);
    ($subsys_or_port2, $_) = id_to_name($b);

    print "${str1}: ${subsys_or_port1}\n";
    print "${str2}: ${subsys_or_port2}\n";

    # 1 junctions go last
    if (($type1 eq '1') and ($type2 ne '1')) {
	$retval = +1;
    } elsif (($type1 ne '1') and ($type2 eq '1')) {
	$retval = -1;
    # 0 junctions go before them
    } elsif (($type1 eq '0') and ($type2 ne '0')) {
	$retval = +1;
    } elsif (($type1 ne '0') and ($type2 eq '0')) {
	$retval = -1;
    # ports go first
    } elsif (($subsys_or_port1 ne 'ports') and
	     ($subsys_or_port2 eq 'ports')) {
	$retval = +1;
    } elsif (($subsys_or_port1 eq 'ports') and
	     ($subsys_or_port2 ne 'ports')) {
	$retval = -1;
    # sort by type:name
    } else {
	$retval = ($str1 cmp $str2);
    }

    return $retval;
}

sub output_abg {
    my ($cr,$rep,$stat,$NM,$type,$arg,$bond_id,$start,$end,@clist,$connections,
	$strlength,$subsys_or_port);

    print_debug("WRITING OUTPUT TO STDIO...\n");
    $stat = "-1";

    output_abg_header();
    
    # order component id's alphabetically by (type:name)
    my (@id_list);
    @id_list = keys (%component_id_tag);
    @id_list = sort sort_components @id_list;

    foreach my $id (@id_list) {
	($subsys_or_port,$_) = id_to_name($id);
	remove_brackets(); $NM = $_;

	$type = $component_id_type{$id};

	$cr = "" unless defined($cr = $component_label_data{$NM}[1]);
	$arg = "" unless defined($arg = $component_label_data{$NM}[2]);
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
		 $mtt_bond_id_index{$bond_id}) if $end eq $id;
	}
	$connections = join(" ",@clist);

	output_component($NM,$type,$cr,$arg,$rep,$stat,$connections,$subsys_or_port);
    }
    
    # order component id's so that entries found in _lbl.txt file are
    # in _lbl file order, and other entries follow.
    my (@id_list);
    @id_list = keys(%component_id_tag);
    @id_list = sort by_label_file @id_list;

    # calculate string length of longest component name (for octave):
    $strlength=0;
    foreach my $compname (@id_list) {
	my $name = id_to_name($compname);
	$strlength = length($name) if length($name) > $strlength;
    };

    print OUT "# Ordered list of Port names\n";
    my $i=1;
    foreach my $id (@id_list) {
	my ($subsys_or_port,$name) = id_to_name($id);







<
<
<
<
<
<


|
|







413
414
415
416
417
418
419






420
421
422
423
424
425
426
427
428
429
430
		 $mtt_bond_id_index{$bond_id}) if $end eq $id;
	}
	$connections = join(" ",@clist);

	output_component($NM,$type,$cr,$arg,$rep,$stat,$connections,$subsys_or_port);
    }
    






    # calculate string length of longest component name (for octave):
    $strlength=0;
    foreach my $id (@id_list) {
	my $name = id_to_name($id);
	$strlength = length($name) if length($name) > $strlength;
    };

    print OUT "# Ordered list of Port names\n";
    my $i=1;
    foreach my $id (@id_list) {
	my ($subsys_or_port,$name) = id_to_name($id);


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