Skip to content

Commit

Permalink
Merge pull request #642 from tobser/pclbus_remove_smartmatch
Browse files Browse the repository at this point in the history
PCLBUS: replace experimental smartmach operator with grep
  • Loading branch information
hplato authored Dec 4, 2016
2 parents 954795c + f59b477 commit 46c5408
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/PLCBUS.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use strict;
use warnings;
use Time::HiRes;
use experimental 'smartmatch';
use Group;
use Process_Item;
use IO::Socket::INET;
Expand Down Expand Up @@ -536,7 +535,7 @@ sub _handle_incoming_commands {
}
if ( $self->{current_cmd}->{expected_response}
&& !$dec->{REPRQ}
&& $cmd ~~ ( $self->{current_cmd}->{expected_response} ) )
&& grep { $_ eq $cmd } @{ $self->{current_cmd}->{expected_response} } )
{
$self->{current_cmd}->{expected_response_seen} = 1;

Expand Down Expand Up @@ -1830,16 +1829,16 @@ sub preset_dim {
$self->command( 'presetdim', $bright_percent, $fade_rate_secs );
}

my @light_cmds = [ "on", "off", "bright", "dim" ];
my @plc_cmds = [
my @light_cmds = ( "on", "off", "bright", "dim" );
my @plc_cmds = (
"status req",
"blink",
"status on",
"status off",
"get signal strength",
"get noise strength",
"all scenes addrs erase",
];
);

sub set {
my ( $self, $new_state, $setby, $respond ) = @_;
Expand All @@ -1849,13 +1848,13 @@ sub set {
$l .= "respond $respond " if $respond;
$self->_logd($l);

if ( $new_state ~~ @light_cmds ) {
if ( grep { $new_state eq $_ } @light_cmds ) {
if ($self->{state} && $new_state eq $self->{state} ) {
$self->_logd("Already in state $new_state, sending command anyway");
}
$self->command( $new_state, undef, undef, $setby, $respond );
}
elsif ( $new_state ~~ @plc_cmds ) {
elsif ( grep { $_ eq $new_state } @plc_cmds ) {
$new_state =~ s/ /_/g;
$self->command( $new_state, undef, undef, $setby, $respond );
}
Expand Down

0 comments on commit 46c5408

Please sign in to comment.