mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-05-05 22:11:12 +08:00
better handling of streaming and non-streaming plotting
Ignore-this: f7cbc85b0382a4810db13d01e65f4bd5 darcs-hash:20090827173055-0cb85-aec6122e4405eb8a1f9d5bd61bf683c47837cba0.gz
This commit is contained in:
parent
3d5760a361
commit
ff04048382
@ -72,8 +72,12 @@ my $xwindow = $options{"xlen"};
|
||||
|
||||
# now start the data acquisition and plotting threads
|
||||
my $dataQueue = Thread::Queue->new();
|
||||
|
||||
|
||||
if($options{"stream"})
|
||||
{
|
||||
my $addThr = threads->create(\&mainThread);
|
||||
my $plotThr = threads->create(\&plotThread) if(!$options{"stream"});
|
||||
my $plotThr = threads->create(\&plotThread);
|
||||
|
||||
while(<>)
|
||||
{
|
||||
@ -84,8 +88,17 @@ $dataQueue->enqueue("Plot now");
|
||||
$dataQueue->enqueue(undef);
|
||||
|
||||
$addThr->join();
|
||||
$plotThr->join() if(!$options{"stream"});
|
||||
|
||||
$plotThr->join();
|
||||
}
|
||||
else
|
||||
{
|
||||
while(<>)
|
||||
{
|
||||
$dataQueue->enqueue($_);
|
||||
}
|
||||
$dataQueue->enqueue(undef);
|
||||
mainThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -100,7 +113,7 @@ sub plotThread
|
||||
|
||||
sub mainThread {
|
||||
local *PIPE;
|
||||
open PIPE, "|gnuplot" || die "Can't initialize gnuplot\n";
|
||||
open PIPE, "|gnuplot --persist" || die "Can't initialize gnuplot\n";
|
||||
autoflush PIPE 1;
|
||||
|
||||
my $temphardcopyfile;
|
||||
@ -195,6 +208,7 @@ sub mainThread {
|
||||
}
|
||||
}
|
||||
|
||||
# read in all of the data
|
||||
if($options{"stream"})
|
||||
{
|
||||
print PIPE "exit;\n";
|
||||
@ -224,7 +238,6 @@ sub mainThread {
|
||||
return;
|
||||
}
|
||||
}
|
||||
sleep 100000;
|
||||
}
|
||||
|
||||
sub cutOld
|
||||
|
Loading…
Reference in New Issue
Block a user