Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCLBUS: replace experimental smartmach operator with grep #642

Merged
merged 1 commit into from
Dec 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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