better handling of streaming and non-streaming plotting

Ignore-this: f7cbc85b0382a4810db13d01e65f4bd5

darcs-hash:20090827173055-0cb85-aec6122e4405eb8a1f9d5bd61bf683c47837cba0.gz
This commit is contained in:
Dima Kogan 2009-08-27 10:30:55 -07:00
parent 3d5760a361
commit ff04048382

View File

@ -72,20 +72,33 @@ my $xwindow = $options{"xlen"};
# now start the data acquisition and plotting threads # now start the data acquisition and plotting threads
my $dataQueue = Thread::Queue->new(); my $dataQueue = Thread::Queue->new();
my $addThr = threads->create(\&mainThread);
my $plotThr = threads->create(\&plotThread) if(!$options{"stream"});
while(<>)
if($options{"stream"})
{ {
$dataQueue->enqueue($_); my $addThr = threads->create(\&mainThread);
my $plotThr = threads->create(\&plotThread);
while(<>)
{
$dataQueue->enqueue($_);
}
$dataQueue->enqueue("Plot now");
$dataQueue->enqueue(undef);
$addThr->join();
$plotThr->join();
}
else
{
while(<>)
{
$dataQueue->enqueue($_);
}
$dataQueue->enqueue(undef);
mainThread();
} }
$dataQueue->enqueue("Plot now");
$dataQueue->enqueue(undef);
$addThr->join();
$plotThr->join() if(!$options{"stream"});
@ -100,7 +113,7 @@ sub plotThread
sub mainThread { sub mainThread {
local *PIPE; local *PIPE;
open PIPE, "|gnuplot" || die "Can't initialize gnuplot\n"; open PIPE, "|gnuplot --persist" || die "Can't initialize gnuplot\n";
autoflush PIPE 1; autoflush PIPE 1;
my $temphardcopyfile; my $temphardcopyfile;
@ -195,6 +208,7 @@ sub mainThread {
} }
} }
# read in all of the data
if($options{"stream"}) if($options{"stream"})
{ {
print PIPE "exit;\n"; print PIPE "exit;\n";
@ -224,7 +238,6 @@ sub mainThread {
return; return;
} }
} }
sleep 100000;
} }
sub cutOld sub cutOld