OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [lib/] [perl/] [temp.pl] - Diff between revs 16 and 24

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 16 Rev 24
Line 1... Line 1...
#! /usr/bin/perl -w
 
use Glib qw/TRUE FALSE/;
 
 
 
use strict;
 
use warnings;
 
 
 
 
 
 
 
 
 
 
 
my @nums=(0,2,3,6,7);
 
 
 
 my $s=compress_nums(@nums);
 
 
 
print "$s\n";
 
 
 
 
 
sub compress_nums{
 
        my      @nums=@_;
 
        my @f=sort { $a <=> $b } @nums;
 
        my $s;
 
        my $ls;
 
        my $range=0;
 
        my $x;
 
 
 
 
use Glib qw/TRUE FALSE/;
 
use Gtk2 '-init';
 
 
        foreach my $p (@f){
our $spinner1;
                if(!defined $x) {
 
                        $s="$p";
 
                        $ls=$p;
 
 
 
 
sub get_value
 
{
 
        my ($button, $format) = @_;
 
 
 
        if ('int' eq $format)
 
        {
 
                $button->{val_label}->set_text (sprintf ("%d",
 
                                $spinner1->get_value_as_int));
                }
                }
                else{
        else
                        if($p-$x>1){ #gap exist
        {
                                if( $range){
                $button->{val_label}->set_text (sprintf ("%0.*f",
                                        $s=($x-$ls>1 )? "$s:$x,$p": "$s,$x,$p";
                                $spinner1->get_digits,
                                        $ls=$p;
                                $spinner1->get_value));
                                        $range=0;
 
                                }else{
 
                                $s= "$s,$p";
 
                                $ls=$p;
 
 
 
                                }
                                }
 
 
                        }else {$range=1;}
 
 
 
 
 
 
 
                }
                }
 
 
                $x=$p
$window = Gtk2::Window->new ('toplevel');
        }
$window->signal_connect (destroy => sub { Gtk2->main_quit; 0; });
        if($range==1){ $s= ($x-$ls>1 )? "$s:$x":  "$s,$x";}
$window->set_title ("Spin Button");
        #update $s($ls,$hs);
 
 
$main_vbox = Gtk2::VBox->new (FALSE, 5);
 
$main_vbox->set_border_width (10);
 
$window->add ($main_vbox);
 
 
 
$frame = Gtk2::Frame->new ("Not accelerated");
 
$main_vbox->pack_start ($frame, TRUE, TRUE, 0);
 
 
 
$vbox = Gtk2::VBox->new (FALSE, 0);
 
$vbox->set_border_width (10);
 
$frame->add ($vbox);
 
 
 
# Day, month, year spinners
 
$hbox = Gtk2::HBox->new (FALSE, 0);
 
$vbox->pack_start ($hbox, TRUE, TRUE, 5);
 
 
 
$vbox2 = Gtk2::VBox->new (FALSE, 0);
 
$hbox->pack_start ($vbox2, TRUE, TRUE, 5);
 
 
 
$label = Gtk2::Label->new ("Day :");
 
$label->set_alignment (0.0, 0.5);       # left halignment, middle valignment
 
$vbox2->pack_start ($label, FALSE, TRUE, 0);
 
 
 
$adj = Gtk2::Adjustment->new (1.0, 1.0, 31.0, 1.0, 5.0, 0.0);
 
$spinner = Gtk2::SpinButton->new ($adj, 0, 0);
 
$spinner->set_wrap (TRUE);
 
$vbox2->pack_start ($spinner, FALSE, TRUE, 0);
 
 
 
$vbox2 = Gtk2::VBox->new (FALSE, 0);
 
$hbox->pack_start ($vbox2, TRUE, TRUE, 5);
 
 
 
$label = Gtk2::Label->new ("Month :");
 
$label->set_alignment (0.0, 0.5);       # left halignment, middle valignment
 
$vbox2->pack_start ($label, FALSE, TRUE, 0);
 
 
 
$adj = Gtk2::Adjustment->new (1.0, 1.0, 12.0, 1.0, 5.0, 0.0);
 
$spinner = Gtk2::SpinButton->new ($adj, 0, 0);
 
$spinner->set_wrap (TRUE);
 
$vbox2->pack_start ($spinner, FALSE, TRUE, 0);
 
 
 
$vbox2 = Gtk2::VBox->new (FALSE, 0);
 
$hbox->pack_start ($vbox2, TRUE, TRUE, 5);
 
 
 
$label = Gtk2::Label->new ("Year :");
 
$label->set_alignment (0.0, 0.5);       # left halignment, middle valignment
 
$vbox2->pack_start ($label, FALSE, TRUE, 0);
 
 
 
$adj = Gtk2::Adjustment->new (1998.0, 1.0, 2100.0, 1.0, 100.0, 0.0);
 
$spinner = Gtk2::SpinButton->new ($adj, 0, 0);
 
$spinner->set_wrap (TRUE);
 
$spinner->set_size_request (55, -1);
 
$vbox2->pack_start ($spinner, FALSE, TRUE, 0);
 
 
 
$frame = Gtk2::Frame->new ("Accelerated");
 
$main_vbox->pack_start ($frame, TRUE, TRUE, 0);
 
 
 
$vbox = Gtk2::VBox->new (FALSE, 0);
 
$vbox->set_border_width (5);
 
$frame->add ($vbox);
 
 
 
$hbox = Gtk2::HBox->new (FALSE, 0);
 
$vbox->pack_start ($hbox, TRUE, TRUE, 5);
 
 
 
$vbox2 = Gtk2::VBox->new (FALSE, 0);
 
$hbox->pack_start ($vbox2, TRUE, TRUE, 5);
 
 
 
$label = Gtk2::Label->new ("Value :");
 
$label->set_alignment (0.0, 0.5);       # left halignment, middle valignment
 
$vbox2->pack_start ($label, FALSE, TRUE, 0);
 
 
 
$adj = Gtk2::Adjustment->new (0.0, -10000.0, 10000.0, 0.5, 100.0, 0.0);
 
$spinner1 = Gtk2::SpinButton->new ($adj, 1.0, 2);
 
$spinner1->set_wrap (TRUE);
 
$spinner1->set_size_request (100, -1);
 
$vbox2->pack_start ($spinner1, FALSE, TRUE, 0);
 
 
 
$vbox2 = Gtk2::VBox->new (FALSE, 0);
 
$hbox->pack_start ($vbox2, TRUE, TRUE, 5);
 
 
 
$label = Gtk2::Label->new ("Digits :");
 
$label->set_alignment (0.0, 0.5);       # left halignment, middle valignment
 
$vbox2->pack_start ($label, FALSE, TRUE, 0);
 
 
 
$adj = Gtk2::Adjustment->new (2, 1, 5, 1, 1, 0);
 
$spinner2 = Gtk2::SpinButton->new ($adj, 0.0, 0);
 
$spinner2->set_wrap (TRUE);
 
$adj->signal_connect (value_changed => sub {
 
                $spinner1->set_digits ($spinner2->get_value_as_int ());
 
        });
 
$vbox2->pack_start ($spinner2, FALSE, TRUE, 0);
 
 
 
$button = Gtk2::CheckButton->new ("Snap to 0.5-ticks");
 
$button->signal_connect (clicked => sub {
 
                $spinner1->set_snap_to_ticks ($_[0]->get_active);
 
        });
 
$vbox->pack_start ($button, TRUE, TRUE, 0);
 
$button->set_active (TRUE);
 
 
 
$button = Gtk2::CheckButton->new ("Numeric only input mode");
 
$button->signal_connect (clicked => sub {
 
                $spinner1->set_numeric ($_[0]->get_active);
 
        });
 
$vbox->pack_start ($button, TRUE, TRUE, 0);
 
$button->set_active (TRUE);
 
 
 
$val_label = Gtk2::Label->new ("");
 
 
 
$hbox = Gtk2::HBox->new (FALSE, 0);
 
$vbox->pack_start ($hbox, FALSE, TRUE, 5);
 
$button = Gtk2::Button->new ("Value as Int");
 
$button->{val_label} = $val_label;
 
$button->signal_connect (clicked => \&get_value, 'int');
 
$hbox->pack_start ($button, TRUE, TRUE, 5);
 
 
 
$button = Gtk2::Button->new ("Value as Float");
 
$button->{val_label} = $val_label;
 
$button->signal_connect (clicked => \&get_value, 'float');
 
$hbox->pack_start ($button, TRUE, TRUE, 5);
 
 
 
$vbox->pack_start ($val_label, TRUE, TRUE, 0);
 
$val_label->set_text ("0");
 
 
 
$hbox = Gtk2::HBox->new (FALSE, 0);
 
$main_vbox->pack_start ($hbox, FALSE, TRUE, 0);
 
 
 
$button = Gtk2::Button->new ("Close");
 
$button->signal_connect (clicked => sub { $window->destroy; });
 
$hbox->pack_start ($button, TRUE, TRUE, 0);
 
 
        return $s;
$window->show_all;
 
 
}
Gtk2->main;
 
 
 
0;
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.