diff options
Diffstat (limited to 'xpp/utils/xpp_sync')
-rwxr-xr-x | xpp/utils/xpp_sync | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/xpp/utils/xpp_sync b/xpp/utils/xpp_sync index e1258d9..d03c0a4 100755 --- a/xpp/utils/xpp_sync +++ b/xpp/utils/xpp_sync @@ -82,6 +82,22 @@ sub unique_xbus(@) { my $curr_sync = Zaptel::Xpp::sync; my @sync_xpds = unique_xbus(get_sorted_xpds()); +sub show_sync() { + foreach my $xpd (@sync_xpds) { + my $xbus = $xpd->xbus; + my @xpds = $xbus->xpds; + my @types = map { $_->type } @xpds; + my $mark = ($curr_sync =~ /\d+/ and $xbus->num == $curr_sync)?"+":""; + printf "\t%1s %s [ ", $mark, $xbus->name; + foreach my $x (sort { $a->num <=> $b->num } @xpds) { + printf "%-3s ", $x->type; + } + print "]"; + my $padding = ' ' x (4 * (8 - @xpds)); + printf "%s (%s)\n", $padding, $xbus->connector; + } +} + sub check_fxo_host_sync() { my @host_synced_xpds = grep { $_->xbus->num() ne $curr_sync } @sync_xpds; my @host_synced_fxos = grep($_->type eq 'FXO', @host_synced_xpds); @@ -111,29 +127,7 @@ if($sync) { } else { print "Current sync: ", $curr_sync, "\n"; print "Best Available Syncers:\n"; - foreach my $xpd (@sync_xpds) { - my $xbus = $xpd->xbus; - my @xpds = $xbus->xpds; - my @types = map { $_->type } @xpds; - my $mark = ($curr_sync =~ /\d+/ and $xbus->num == $curr_sync)?"+":""; - printf "\t%1s %s [ ", $mark, $xbus->name; - my $next = 0; - foreach my $x (sort { $a->num <=> $b->num } @xpds) { - my $n = $x->num; - # Fill spaces - for(my $i = $next; $i < $n; $i++) { - printf "%-3s ", ""; - } - printf "%-3s ", $x->type; - $next = $n + 1; - } - # Fill spaces to end - my $n = 4; - for(my $i = $next; $i < $n; $i++) { - printf "%-3s ", ""; - } - printf "] (%s)\n", $xbus->connector; - } + show_sync; check_fxo_host_sync; } |