Store last command for continuous moves so that moveStop can send the correct stop command

This commit is contained in:
Isaac Connor 2021-04-14 17:19:01 -04:00
parent 113e495a7d
commit 7489c3850d
1 changed files with 33 additions and 20 deletions

View File

@ -187,67 +187,74 @@ sub moveAbs ## Up, Down, Left, Right, etc. ??? Doesn't make sense here...
sub moveConUp { sub moveConUp {
my $self = shift; my $self = shift;
Debug('Move Up'); Debug('Move Up');
$$self{LastMove} = 'code=Up&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Up&channel=0&arg1=0&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Up&channel=0&arg1=0&arg2=1&arg3=0');
usleep(500); ##XXX Should this be passed in as a "speed" parameter? #usleep(500); ##XXX Should this be passed in as a "speed" parameter?
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Up&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Up&channel=0&arg1=0&arg2=1&arg3=0');
} }
sub moveConDown { sub moveConDown {
my $self = shift; my $self = shift;
Debug('Move Down'); Debug('Move Down');
$$self{LastMove} = 'code=Down&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Down&channel=0&arg1=0&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Down&channel=0&arg1=0&arg2=1&arg3=0');
usleep(500); #usleep(500);
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Down&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Down&channel=0&arg1=0&arg2=1&arg3=0');
} }
sub moveConLeft { sub moveConLeft {
my $self = shift; my $self = shift;
Debug('Move Left'); Debug('Move Left');
$$self{LastMove} = 'code=Left&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Left&channel=0&arg1=0&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Left&channel=0&arg1=0&arg2=1&arg3=0');
usleep(500); #usleep(500);
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Left&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Left&channel=0&arg1=0&arg2=1&arg3=0');
} }
sub moveConRight { sub moveConRight {
my $self = shift; my $self = shift;
Debug('Move Right'); Debug('Move Right');
# $self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=PositionABS&channel=0&arg1=270&arg2=5&arg3=0' ); $$self{LastMove} = 'code=Right&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Right&channel=0&arg1=0&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=Right&channel=0&arg1=0&arg2=1&arg3=0');
usleep(500); #usleep(500);
Debug('Move Right Stop'); #Debug('Move Right Stop');
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Right&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=Right&channel=0&arg1=0&arg2=1&arg3=0');
} }
sub moveConUpRight { sub moveConUpRight {
my $self = shift; my $self = shift;
Debug('Move Diagonally Up Right'); Debug('Move Diagonally Up Right');
$$self{LastMove} = 'code=RightUp&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=RightUp&channel=0&arg1=1&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=RightUp&channel=0&arg1=1&arg2=1&arg3=0');
usleep(500); #usleep(500);
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=RightUp&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=RightUp&channel=0&arg1=0&arg2=1&arg3=0');
} }
sub moveConDownRight { sub moveConDownRight {
my $self = shift; my $self = shift;
Debug('Move Diagonally Down Right'); Debug('Move Diagonally Down Right');
$$self{LastMove} = 'code=RightDown&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=RightDown&channel=0&arg1=1&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=RightDown&channel=0&arg1=1&arg2=1&arg3=0');
usleep(500); #usleep(500);
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=RightDown&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=RightDown&channel=0&arg1=0&arg2=1&arg3=0');
} }
sub moveConUpLeft { sub moveConUpLeft {
my $self = shift; my $self = shift;
Debug('Move Diagonally Up Left'); Debug('Move Diagonally Up Left');
$$self{LastMove} = 'code=LeftUp&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=LeftUp&channel=0&arg1=1&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=LeftUp&channel=0&arg1=1&arg2=1&arg3=0');
usleep(500); #usleep(500);
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=LeftUp&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=LeftUp&channel=0&arg1=0&arg2=1&arg3=0');
} }
sub moveConDownLeft { sub moveConDownLeft {
my $self = shift; my $self = shift;
Debug('Move Diagonally Down Left'); Debug('Move Diagonally Down Left');
$$self{LastMove} = 'code=LeftDown&channel=0&arg1=0&arg2=1&arg3=0';
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=LeftDown&channel=0&arg1=1&arg2=1&arg3=0'); $self->sendCmd('cgi-bin/ptz.cgi?action=start&code=LeftDown&channel=0&arg1=1&arg2=1&arg3=0');
usleep (500); #usleep (500);
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=LeftDown&channel=0&arg1=0&arg2=1&arg3=0'); #$self->sendCmd('cgi-bin/ptz.cgi?action=stop&code=LeftDown&channel=0&arg1=0&arg2=1&arg3=0');
} }
# Stop is not "correctly" implemented as control_functions.php translates this to "Center" # Stop is not "correctly" implemented as control_functions.php translates this to "Center"
@ -256,8 +263,14 @@ sub moveConDownLeft {
sub moveStop { sub moveStop {
my $self = shift; my $self = shift;
Debug('Move Stop/Center'); if ($$self{LastMove}) {
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=PositionABS&channel=0&arg1=0&arg2=0&arg3=0&arg4=1'); Debug('Move Stop '.$$self{LastMove});
$self->sendCmd('cgi-bin/ptz.cgi?action=stop&'.$$self{LastMove});
$$self{LastMove} = '';
} else {
Debug('Move Stop/Center');
$self->sendCmd('cgi-bin/ptz.cgi?action=start&code=PositionABS&channel=0&arg1=0&arg2=0&arg3=0&arg4=1');
}
} }
# Move Camera to Home Position # Move Camera to Home Position