Overview
Comment: | Started modifying to write ibg.m - only writes component connection data so far. Found a bug in abg.m generation (not fixed) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8bb63d003f961a24b311f4158d445482 |
User & Date: | geraint@users.sourceforge.net on 2004-07-31 02:00:26 |
Other Links: | branch diff | manifest | tags |
Context
2004-07-31
| ||
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 | |
02:00:26 |
Started modifying to write ibg.m - only writes component connection data so far. Found a bug in abg.m generation (not fixed) | |
2004-07-29
| ||
17:46:45 | Removed error if label file has less than three fields. check-in: de8a6e6d8a user: geraint@users.sourceforge.net tags: origin/master, trunk | |
Changes
Modified mttroot/mtt/bin/trans/dia2abg.pl from [3a7a725f01] to [632bc129d5].
︙ | ︙ | |||
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 | 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 $abg_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, 'label_file=s' => \$label_file, 'component_list_file=s' => \$component_list_file, 'debug' => \$debug, 'create_component_list' => \$create_component_list, 'create_abg' => \$create_abg, 'abg_file=s' => \$abg_file, 'change_flow_causality=s' => \$change_flow_causality, 'change_effort_causality=s' => \$change_effort_causality, ); die usage() if $diagram_name eq ''; # Use defaults if necessary: $dia_input_file = $diagram_name . "_abg.dia" if ($dia_input_file eq ''); $dia_output_file = $diagram_name . "_cbg.dia" if ($dia_output_file eq ''); $label_file = $diagram_name . "_lbl.txt" if ($label_file eq ''); $abg_file = $diagram_name . "_abg.m" if ($abg_file eq ''); $component_list_file = $diagram_name . "_cmp.txt" if ($component_list_file eq ''); # Start Parsing XML, and creating files: my $dom = new XML::DOM::Parser; my ($doc); $doc = $dom->parsefile($dia_input_file); | > > > > | 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 | 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, 'label_file=s' => \$label_file, 'component_list_file=s' => \$component_list_file, 'debug' => \$debug, 'create_component_list' => \$create_component_list, 'create_abg' => \$create_abg, 'abg_file=s' => \$abg_file, 'ibg_file=s' => \$ibg_file, 'change_flow_causality=s' => \$change_flow_causality, 'change_effort_causality=s' => \$change_effort_causality, ); die usage() if $diagram_name eq ''; # Use defaults if necessary: $dia_input_file = $diagram_name . "_abg.dia" if ($dia_input_file eq ''); $dia_output_file = $diagram_name . "_cbg.dia" if ($dia_output_file eq ''); $label_file = $diagram_name . "_lbl.txt" if ($label_file eq ''); $abg_file = $diagram_name . "_abg.m" if ($abg_file eq ''); $ibg_file = $diagram_name . "_ibg.m" if ($ibg_file eq ''); $component_list_file = $diagram_name . "_cmp.txt" if ($component_list_file eq ''); # Start Parsing XML, and creating files: my $dom = new XML::DOM::Parser; my ($doc); $doc = $dom->parsefile($dia_input_file); |
︙ | ︙ | |||
149 150 151 152 153 154 155 156 157 158 159 160 161 162 | get_label_data(); output_abg(); output_bond_causality(); parse_aliases(); print OUT "endfunction\n"; } if ($change_flow_causality ne '' || $change_effort_causality ne '') { open (DIA_OUT,">$dia_output_file") || die "Cannot open $dia_output_file for writing.\n"; print DIA_OUT $doc->toString; close DIA_OUT; } | > > > > > > > > > | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | get_label_data(); output_abg(); output_bond_causality(); parse_aliases(); print OUT "endfunction\n"; } if ($create_ibg) { open (OUT,">$ibg_file") || die "Cannot open $ibg_file for writing.\n"; # don't bother about creating cmp.m simultaneously # don't need getting label data output_ibg(); } if ($change_flow_causality ne '' || $change_effort_causality ne '') { open (DIA_OUT,">$dia_output_file") || die "Cannot open $dia_output_file for writing.\n"; print DIA_OUT $doc->toString; close DIA_OUT; } |
︙ | ︙ | |||
260 261 262 263 264 265 266 267 268 269 270 271 272 273 | # Generated by dia2abg.pl on $date # The file is in Octave format # Subsystems and Ports EOF } sub output_component { my ($NM,$type,$cr,$arg,$rep,$stat,$connections,$subsys_or_port) = @_; $_=$NM; remove_brackets(); $NM = $_; my $pretty_name = ($subsys_or_port eq "ports") ? "Port" : "Component"; | > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # Generated by dia2abg.pl on $date # The file is in Octave format # Subsystems and Ports EOF } sub output_ibg_header { my ($date); $date = `date`; chomp($date); print OUT <<"EOF"; ## -*-octave-*- put Emacs into Octave mode function [${diagram_name}] = ${diagram_name}_ibg ## Intermediate bond graph representation of $diagram_name ## Generated by MTT on $date ## head refers to the harpoon end of a bond ## tail refers to the other end of a bond ## causality.? is the end at which ? is imposed EOF } sub output_ibg_footer { print OUT <<"EOF"; endfunction EOF } sub output_component { my ($NM,$type,$cr,$arg,$rep,$stat,$connections,$subsys_or_port) = @_; $_=$NM; remove_brackets(); $NM = $_; my $pretty_name = ($subsys_or_port eq "ports") ? "Port" : "Component"; |
︙ | ︙ | |||
365 366 367 368 369 370 371 372 373 374 375 376 377 378 | print OUT " " . $diagram_name . ".subsystemlist($i,:)" . ' = "' . $name . " " x ($strlength - length($name)) . '";' . "\n"; $i++; } } print OUT "\n"; } sub output_bond_causality { my ($mtt_bond_id,$dia_bond_id,$mtt_flow_causality,$mtt_effort_causality, %reverse_mtt_bond_id_index); print OUT "# Bonds\n"; print OUT " $diagram_name.bonds = [\n"; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 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 484 485 486 487 | print OUT " " . $diagram_name . ".subsystemlist($i,:)" . ' = "' . $name . " " x ($strlength - length($name)) . '";' . "\n"; $i++; } } print OUT "\n"; } 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, $anon_id); # copy component_id_tag and assign names to anonymous components %components = %component_id_tag; $anon_id = 0; while (($id, $component) = each(%components)) { $component =~ s/\#//g; ($type, $name) = split (/:/, $component); if (! $name) { $component = "${component}:mtt${type}_${anon_id}"; } $anon_id++; $components{$id} = $component; } output_ibg_header(); %reverse_mtt_bond_id_index = reverse (%mtt_bond_id_index); # while (($mtt_bond_id, $dia_bond_id) = each(%reverse_mtt_bond_id_index)) { @bonds = (sort keys (%reverse_mtt_bond_id_index)); foreach $mtt_bond_id (@bonds) { $dia_bond_id = $reverse_mtt_bond_id_index{$mtt_bond_id}; $start = $bond_id_start_id{$dia_bond_id}; $end = $bond_id_end_id {$dia_bond_id}; if ($bond_id_arrow_on_start{$dia_bond_id}) { $head = $end; $tail = $start; } else { $head = $start; $tail = $end; } $head_component = $components{$head}; $tail_component = $components{$tail}; 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" . " ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." . "tail.ports = \"FIXME!\";\n"; print OUT " ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." . "causality.effort = \"FIXME!\";\n" . " ${diagram_name}.bonds.bond${mtt_bond_id_index{$dia_bond_id}}." . "causality.flow = \"FIXME!\";\n\n"; } output_ibg_footer(); } sub output_bond_causality { my ($mtt_bond_id,$dia_bond_id,$mtt_flow_causality,$mtt_effort_causality, %reverse_mtt_bond_id_index); print OUT "# Bonds\n"; print OUT " $diagram_name.bonds = [\n"; |
︙ | ︙ |