fix: Uniview PTZ moves use a default speed when none is sent refs #6777

This commit is contained in:
Jash committed 2026-11-19 10:42:54 +05:30
1 parent b529a752b3
commit 60ae929aaa
2 files changed
+38 -3

No files matched your search

@@ -55,6 +55,10 @@ use JSON::MaybeXS qw(encode_json decode_json);
my $ChannelID = 1; # Usually...
my $DefaultFocusSpeed = 50; # Should be between 1 and 100
my $DefaultIrisSpeed = 50; # Should be between 1 and 100
# Used when the Controls row has no pan/tilt/zoom speed, so the UI sends none.
my $DefaultPanSpeed = 50; # Should be between 1 and 100
my $DefaultTiltSpeed = 50; # Should be between 1 and 100
my $DefaultZoomSpeed = 50; # Should be between 1 and 100
my %config_types = (
'LAPI/V1.0/System/DeviceBasicInfo' => {},
@@ -275,9 +279,9 @@ sub moveVector {
$command = "ISAPI/PTZCtrl/channels/$ChannelID/continuous";
}
# Calculate movement speeds
my $x = $pandirection * $self->getParam( $params, 'panspeed', 0 );
my $y = $tiltdirection * $self->getParam( $params, 'tiltspeed', 0 );
my $z = $zoomdirection * $self->getParam( $params, 'speed', 0 );
my $x = $pandirection * $self->getParam( $params, 'panspeed', $DefaultPanSpeed );
my $y = $tiltdirection * $self->getParam( $params, 'tiltspeed', $DefaultTiltSpeed );
my $z = $zoomdirection * $self->getParam( $params, 'speed', $DefaultZoomSpeed );
# Create the XML
my $xml = "<PTZData><pan>$x</pan><tilt>$y</tilt><zoom>$z</zoom>$momentxml</PTZData>";
# Send it to the camera
+31
View File
@@ -0,0 +1,31 @@
use strict;
use warnings;
use Test::More;
# The UI only sends --panspeed/--tiltspeed/--speed when the Controls row
# has HasPanSpeed/HasTiltSpeed/HasZoomSpeed. Without them a Uniview move
# must still use a non-zero speed, or the camera never moves.
require_ok('ZoneMinder::Control::Uniview');
my @xml;
{
no warnings qw(redefine once);
*ZoneMinder::Control::Uniview::PutCmd = sub { push @xml, $_[2]; return 1; };
}
my $self = bless { Monitor => { AutoStopTimeout => 0 } }, 'ZoneMinder::Control::Uniview';
sub sent { my ($m, $p) = @_; @xml = (); $self->$m($p); return $xml[-1] // ''; }
my ($pan) = sent('moveConLeft', {}) =~ m{<pan>(-?\d+)</pan>};
ok(defined $pan && $pan < 0, 'moveConLeft with no speed pans left') or diag "pan=".($pan//'none');
my ($tilt) = sent('moveConUp', {}) =~ m{<tilt>(-?\d+)</tilt>};
ok(defined $tilt && $tilt > 0, 'moveConUp with no speed tilts up') or diag "tilt=".($tilt//'none');
my ($zoom) = sent('zoomConTele', {}) =~ m{<zoom>(-?\d+)</zoom>};
ok(defined $zoom && $zoom > 0, 'zoomConTele with no speed zooms in') or diag "zoom=".($zoom//'none');
like(sent('moveConLeft', { panspeed => 40 }), qr{<pan>-40</pan>}, 'a given pan speed is still used');
like(sent('moveStop', {}), qr{<pan>0</pan><tilt>0</tilt><zoom>0</zoom>}, 'moveStop still sends zero');
done_testing();