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 41 and 43

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 41 Rev 43
#!/usr/bin/perl
#!/usr/bin/perl -w
 
 
 
 
use strict;
use strict;
use warnings;
use GraphViz;
use Gtk2;
 
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep  clock_gettime clock_getres clock_nanosleep clock stat );
 
use Proc::Background;
 
use IO::CaptureOutput qw(capture qxx qxy);
 
 
 
$ENV{TEMP}="ALIREZA";
 
 
 
 
 
my $cmd =       "xterm -e sh  t.sh";
 
my ($stdout,$exit)=run_cmd_in_back_ground_get_stdout( $cmd);
 
 
 
 
 
 
 
##########
 
#  run external commands
 
##########
 
 
 
sub run_cmd_in_back_ground
 
{
 
  my $command = shift;
 
  #print "\t$command\n";
 
 
 
  ### Start running the Background Job:
 
    my $proc = Proc::Background->new($command);
 
    my $PID = $proc->pid;
 
    my $start_time = $proc->start_time;
 
    my $alive = $proc->alive;
 
 
 
  ### While $alive is NOT '0', then keep checking till it is...
 
  #  *When $alive is '0', it has finished executing.
 
  while($alive ne 0)
 
  {
 
    $alive = $proc->alive;
 
 
 
    # This while loop will cause Gtk2 to conti processing events, if
 
    # there are events pending... *which there are...
 
    while (Gtk2->events_pending) {
 
      Gtk2->main_iteration;
 
    }
 
    Gtk2::Gdk->flush;
 
 
 
    usleep(1000);
 
  }
 
 
 
  my $end_time = $proc->end_time;
 
 # print "*Command Completed at $end_time, with PID = $PID\n\n";
 
 
 
  # Since the while loop has exited, the BG job has finished running:
 
  # so close the pop-up window...
 
 # $popup_window->hide;
 
 
 
  # Get the RETCODE from the Background Job using the 'wait' method
 
  my $retcode = $proc->wait;
 
  $retcode /= 256;
 
 
 
  print "\t*RETCODE == $retcode\n\n";
 
  Gtk2::Gdk->flush;
 
  ### Check if the RETCODE returned with an Error:
 
  if ($retcode ne 0) {
 
    print "Error: The Background Job ($command) returned with an Error...!\n";
 
    return 1;
 
  } else {
 
    #print "Success: The Background Job Completed Successfully...!\n";
 
    return 0;
 
  }
 
 
 
}
 
 
 
 
 
 
 
sub run_cmd_in_back_ground_get_stdout
 
{
 
        my $cmd=shift;
 
        my $exit;
 
        my ($stdout, $stderr);
 
        capture { $exit=run_cmd_in_back_ground($cmd) } \$stdout, \$stderr;
 
        return ($stdout,$exit,$stderr);
 
 
 
}
 
 
 
 
 
 
 
 
 
 
my $g = GraphViz->new();
 
 
 
$g->add_node('London');
 
$g->add_node('Paris', label => 'City of\nlurve');
 
$g->add_node('New York');
 
 
 
$g->add_edge('London' => 'Paris');
 
$g->add_edge('London' => 'New York', label => 'Far');
 
$g->add_edge('Paris' => 'London');
 
 
#system ("sh t.sh");
print $g->as_png;
 
 
 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.