Changeset 377


Ignore:
Timestamp:
Jan 4, 2018, 3:21:55 PM (6 years ago)
Author:
g7moreau
Message:
  • Add support for way in exportsw format txt
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r376 r377  
    30603060
    30613061   my $switch_connection = YAML::Syck::LoadFile("$KLASK_SW_FILE");
    3062 
    3063    if ($args{'way'} eq 'all' or $args{'way'} eq 'desc') {
     3062   my $interway = 0;
     3063
     3064   if ($args{'way'} =~ m/all|desc/) {
     3065      print "\n" if $interway++;
     3066      # Switch description
    30643067      my %db_switch_global = %{$switch_connection->{'switch_db'}};
    30653068      my $arrow            = '0--------->>>>';
     
    30873090   my %db_switch_connected_on_port = %{$switch_connection->{'connected_on_port'}};
    30883091
    3089    # Switch output port and parent port connection
    3090    my $tb_child = Text::Table->new( # http://www.perlmonks.org/?node_id=988320
    3091       {align => 'left',   align_title => 'left',   title => 'Child-Switch'},
    3092       {align => 'right',  align_title => 'right',  title => 'Output-Port'},
    3093       {align => 'center', align_title => 'center', title => 'Link'},
    3094       {align => 'left',   align_title => 'left',   title => 'Input-Port'},
    3095       {align => 'left',   align_title => 'left',   title => 'Parent-Switch'},
    3096       );
    3097    for my $sw (sort keys %db_switch_output_port) {
    3098       my $arrow = '--->';
    3099       $arrow = '===>' if $db_switch_output_port{$sw} =~ m/^(Trk|Br|Po)/;
    3100       if (exists $db_switch_parent{$sw}) {
    3101          $tb_child->add($sw, $db_switch_output_port{$sw}, $arrow, $db_switch_parent{$sw}->{'port_hr'}, $db_switch_parent{$sw}->{'switch'});
    3102 
    3103          }
    3104       else {
    3105          $tb_child->add($sw, $db_switch_output_port{$sw}, $arrow, '', 'router');
    3106          }
    3107       }
    3108    my @colrange = map {scalar $tb_child->colrange($_)} (0 .. 4); # force scaler context
    3109    $tb_child->add(map {' ' x $_} reverse @colrange);             # add empty line to force symetric table output
    3110    print $tb_child->title();
    3111    print $tb_child->rule('-');
    3112    print $tb_child->body(0, $tb_child->body_height() - 1);       # remove last fake line
    3113    $tb_child->clear;
    3114 
    3115    # Switch parent and children port inter-connection
    3116    print "\n";
    3117    my $tb_parent = Text::Table->new(                             # http://www.perlmonks.org/?node_id=988320
    3118       {align => 'left',   align_title => 'left',   title => 'Parent-Switch'},
    3119       {align => 'right',  align_title => 'right',  title => 'Input-Port'},
    3120       {align => 'center', align_title => 'center', title => 'Link'},
    3121       {align => 'left',   align_title => 'left',   title => 'Output-Port'},
    3122       {align => 'left',   align_title => 'left',   title => 'Child-Switch'},
    3123       );
    3124    for my $swport (sort keys %db_switch_connected_on_port) {
    3125       my ($sw_connect, $port_connect) = split m/ $SEP_SWITCH_PORT /xms, $swport, 2;
    3126       for my $sw (keys %{$db_switch_connected_on_port{$swport}}) {
    3127          my $arrow = '<---';
    3128          $arrow = '<===' if $port_connect =~ m/^(Trk|Br|Po)/;
    3129          if (exists $db_switch_output_port{$sw}) {
    3130             $tb_parent->add($sw_connect, $port_connect, $arrow, $db_switch_output_port{$sw}, $sw);
     3092   if ($args{'way'} =~ m/all|child/) {
     3093      print "\n" if $interway++;
     3094      # Switch output port and parent port connection
     3095      my $tb_child = Text::Table->new( # http://www.perlmonks.org/?node_id=988320
     3096         {align => 'left',   align_title => 'left',   title => 'Child-Switch'},
     3097         {align => 'right',  align_title => 'right',  title => 'Output-Port'},
     3098         {align => 'center', align_title => 'center', title => 'Link'},
     3099         {align => 'left',   align_title => 'left',   title => 'Input-Port'},
     3100         {align => 'left',   align_title => 'left',   title => 'Parent-Switch'},
     3101         );
     3102      for my $sw (sort keys %db_switch_output_port) {
     3103         my $arrow = '--->';
     3104         $arrow = '===>' if $db_switch_output_port{$sw} =~ m/^(Trk|Br|Po)/;
     3105         if (exists $db_switch_parent{$sw}) {
     3106            $tb_child->add($sw, $db_switch_output_port{$sw}, $arrow, $db_switch_parent{$sw}->{'port_hr'}, $db_switch_parent{$sw}->{'switch'});
     3107
    31313108            }
    31323109         else {
    3133             $tb_parent->add($sw_connect, $port_connect, $arrow, '', $sw);
     3110            $tb_child->add($sw, $db_switch_output_port{$sw}, $arrow, '', 'router');
    31343111            }
    31353112         }
    3136       }
    3137    @colrange = map {scalar $tb_parent->colrange($_)} (0 .. 4); # force scaler context
    3138    $tb_parent->add(map {' ' x $_} reverse @colrange);          # add empty line to force symetric table output
    3139    print $tb_parent->title();
    3140    print $tb_parent->rule('-');
    3141    print $tb_parent->body(0, $tb_parent->body_height() - 1);   # remove last fake line
    3142    $tb_parent->clear;
    3143 
     3113      my @colrange = map {scalar $tb_child->colrange($_)} (0 .. 4); # force scaler context
     3114      $tb_child->add(map {' ' x $_} reverse @colrange);             # add empty line to force symetric table output
     3115      print $tb_child->title();
     3116      print $tb_child->rule('-');
     3117      print $tb_child->body(0, $tb_child->body_height() - 1);       # remove last fake line
     3118      $tb_child->clear;
     3119      }
     3120
     3121   if ($args{'way'} =~ m/all|parent/) {
     3122      print "\n" if $interway++;
     3123      # Switch parent and children port inter-connection
     3124      my $tb_parent = Text::Table->new(                             # http://www.perlmonks.org/?node_id=988320
     3125         {align => 'left',   align_title => 'left',   title => 'Parent-Switch'},
     3126         {align => 'right',  align_title => 'right',  title => 'Input-Port'},
     3127         {align => 'center', align_title => 'center', title => 'Link'},
     3128         {align => 'left',   align_title => 'left',   title => 'Output-Port'},
     3129         {align => 'left',   align_title => 'left',   title => 'Child-Switch'},
     3130         );
     3131      for my $swport (sort keys %db_switch_connected_on_port) {
     3132         my ($sw_connect, $port_connect) = split m/ $SEP_SWITCH_PORT /xms, $swport, 2;
     3133         for my $sw (keys %{$db_switch_connected_on_port{$swport}}) {
     3134            my $arrow = '<---';
     3135            $arrow = '<===' if $port_connect =~ m/^(Trk|Br|Po)/;
     3136            if (exists $db_switch_output_port{$sw}) {
     3137               $tb_parent->add($sw_connect, $port_connect, $arrow, $db_switch_output_port{$sw}, $sw);
     3138               }
     3139            else {
     3140               $tb_parent->add($sw_connect, $port_connect, $arrow, '', $sw);
     3141               }
     3142            }
     3143         }
     3144      @colrange = map {scalar $tb_parent->colrange($_)} (0 .. 4); # force scaler context
     3145      $tb_parent->add(map {' ' x $_} reverse @colrange);          # add empty line to force symetric table output
     3146      print $tb_parent->title();
     3147      print $tb_parent->rule('-');
     3148      print $tb_parent->body(0, $tb_parent->body_height() - 1);   # remove last fake line
     3149      $tb_parent->clear;
     3150      }
    31443151   return;
    31453152   }
Note: See TracChangeset for help on using the changeset viewer.