Overview
Comment:Writes causality information to ibg.m.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 16dc8250f38cf2a359b13fe31cbdf807306a65a5c39951d40c7812eb1ab8ee9e
User & Date: geraint@users.sourceforge.net on 2004-07-31 22:51:55
Other Links: branch diff | manifest | tags
Context
2004-08-01
18:39:50
Writes port data (bond labels) to ibg.m check-in: 1b446b6a1d user: geraint@users.sourceforge.net tags: origin/master, trunk
2004-07-31
22:51:55
Writes causality information to ibg.m. check-in: 16dc8250f3 user: geraint@users.sourceforge.net tags: origin/master, trunk
20:04:08
Patches to allow the user to increase the buffer size of p2c.
(useful if very long lines occur when building with -c option (deprecated)).
check-in: 3a803964f3 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/dia2abg.pl from [632bc129d5] to [193803410a].

85
86
87
88
89
90
91
92


93
94
95
96
97
98
99
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
100







-
+
+







#----------------------------MAIN PROGRAM------------------------------------
use strict;
use Getopt::Long;
use XML::DOM;

my (%component_id_tag, %bond_id_start_id, %bond_id_end_id,
    %component_label_data, $objects, %mtt_bond_id_index,
    %bond_id_arrow_on_start, %bond_id_flow_causality, %bond_id_effort_causality);
    %bond_id_arrow_on_start, %bond_id_flow_causality, %bond_id_effort_causality,
    %bond_id_start_label,%bond_id_end_label);

# Parse user options:
my $diagram_name = '';
my $dia_input_file = '';
my $dia_output_file = '';
my $label_file = '';
my $component_list_file = '';
412
413
414
415
416
417
418



419
420
421
422
423
424
425
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429







+
+
+







sub output_ibg {
    my (%components,$key,$component,$type,$name,
	%reverse_mtt_bond_id_index,$mtt_bond_id,$dia_bond_id,
	@bonds,
	$bond_id,$start,$end,$id,
	$head,$head_component,$head_type,$head_name,
	$tail,$tail_component,$tail_type,$tail_name,
	$start_label,$end_label,
	$head_label,$tail_label,
	$effort_causality,$flow_causality,
	$anon_id);

    # copy component_id_tag and assign names to anonymous components
    %components = %component_id_tag;

    $anon_id = 0;
    while (($id, $component) = each(%components)) {
448
449
450
451
452
453
454














455
456
457
458














459
460
461
462
463
464
465
466
467
468

469
470

471
472
473
474

475
476

477
478
479
480
481
482
483
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499

500
501

502
503
504
505

506
507

508
509
510
511
512
513
514
515







+
+
+
+
+
+
+
+
+
+
+
+
+
+




+
+
+
+
+
+
+
+
+
+
+
+
+
+









-
+

-
+



-
+

-
+







	if ($bond_id_arrow_on_start{$dia_bond_id}) {
	    $head = $end;
	    $tail = $start;
	} else {
	    $head = $start;
	    $tail = $end;
	}

	$start_label = $bond_id_start_label{$dia_bond_id};
	$end_label   = $bond_id_end_label  {$dia_bond_id};

	$start_label =~ s/\#//g;
	$end_label   =~ s/\#//g;

	if ($bond_id_arrow_on_start{$dia_bond_id}) {
	    $head_label = $end_label;
	    $tail_label = $start_label;
	} else {
	    $head_label = $start_label;
	    $tail_label = $end_label;
	}

	$head_component = $components{$head};
	$tail_component = $components{$tail};

	$effort_causality = $bond_id_effort_causality{$dia_bond_id};
	$flow_causality   = $bond_id_flow_causality  {$dia_bond_id};

	for ($effort_causality) {
	    if (/-1/) { $effort_causality = "tail";}
	    if (/0/) { $effort_causality = "none";}
	    if (/1/) { $effort_causality = "head";}
	}
	for ($flow_causality) {
	    if (/-1/) { $flow_causality = "tail";}
	    if (/0/) { $flow_causality = "none";}
	    if (/1/) { $flow_causality = "head";}
	}
		       
	print OUT
	    "  ## bond $mtt_bond_id \n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "head.component = \"${head_component}\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "tail.component = \"${tail_component}\";\n";

	print OUT
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "head.ports = \"FIXME!\";\n" .
	    "head.ports = \"$head_label\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "tail.ports = \"FIXME!\";\n";
	    "tail.ports = \"$tail_label\";\n";

	print OUT
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "causality.effort = \"FIXME!\";\n" .
	    "causality.effort = \"$effort_causality\";\n" .
	    "  ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." .
	    "causality.flow = \"FIXME!\";\n\n";
	    "causality.flow = \"$flow_causality\";\n\n";
    }
    
    output_ibg_footer();
}

sub output_bond_causality {
    my ($mtt_bond_id,$dia_bond_id,$mtt_flow_causality,$mtt_effort_causality,
548
549
550
551
552
553
554









555
556
557
558
559
560
561
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602







+
+
+
+
+
+
+
+
+







    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "effort_causality");
    change_causality($id_index, $attribute, $change_effort_causality);
    $bond_id_effort_causality{$id} = defined($attribute) ? get_dia_attribute_value("dia:enum",$attribute)-1 : 1;

    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "flow_causality");
    change_causality($id_index, $attribute, $change_flow_causality);
    $bond_id_flow_causality{$id} = defined($attribute) ? get_dia_attribute_value("dia:enum",$attribute)-1 : 1;

#    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "start_label");
#    $bond_id_start_label{$id} = defined($attribute) ? get_dia_attribute_value("dia:string") : "[]";
    $bond_id_start_label{$id} = "[]"; # FIXME!

#    $attribute = get_first_subnode_by_nodename_attribute(1,$object_node, "dia:attribute", "name", "end_label");
#    $bond_id_end_label{$id} = defined($attribute) ? get_dia_attribute_value("dia:string") : "[]";
    $bond_id_end_label{$id} = "[]"; # FIXME!

}

sub change_causality() {
    my ($id_index, $attribute_node, $causality_change_string)=@_;
    my ($mtt_id, $arrow_oriented_causality);

    foreach my $id_causality (split(/;/,$causality_change_string)) {


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