cleared up --stream option logic

- minor refactoring
- --hardcopy and --stream together now generate a warning and turn off --stream
This commit is contained in:
Dima Kogan 2013-06-14 23:20:17 -07:00
parent 707196580a
commit 3146dbdfe7

View File

@ -34,18 +34,14 @@ my $dataQueue;
my $latestX; my $latestX;
my $streamingFinished : shared = undef; my $streamingFinished : shared = undef;
if($options{stream}) if($options{stream})
{ {
if( $options{hardcopy})
{
$options{stream} = undef;
}
$dataQueue = Thread::Queue->new(); $dataQueue = Thread::Queue->new();
my $addThr = threads->create(\&mainThread); my $addThr = threads->create(\&mainThread);
# spawn the plot updating thread. If I'm replotting from a data trigger, I don't need this # spawn the plot updating thread. If I'm replotting from a data trigger, I don't need this
my $plotThr = threads->create(\&plotUpdateThread) unless $options{stream} < 0; my $plotThr = threads->create(\&plotUpdateThread) if $options{stream} > 0;
while(<>) while(<>)
{ {
@ -155,14 +151,21 @@ sub interpretCommandline
} }
} }
# parse stream option. Allowed only numbers >= 0 or 'trigger' if ( defined $options->{hardcopy} && defined $options->{stream} )
{
print STDERR "Warning: since we're making a hardcopy, I'm disabling streaming\n";
delete $options->{stream};
}
# parse stream option. Allowed only numbers >= 0 or 'trigger'. After this code
# $options->{stream} is
# -1 for triggered replotting
# >0 for timed replotting
# undef if not streaming
if(defined $options->{stream}) if(defined $options->{stream})
{
if ( $options->{stream} eq '')
{ {
# if no streaming period is given, default to 1Hz. # if no streaming period is given, default to 1Hz.
$options->{stream} = 1; $options->{stream} = 1 if $options->{stream} eq '';
}
if( !looks_like_number $options->{stream} ) if( !looks_like_number $options->{stream} )
{ {