From a96ccd71f791d49c1a09052be69e39a4e5d484e2 Mon Sep 17 00:00:00 2001 From: stan Date: Thu, 10 Nov 2005 12:04:37 +0000 Subject: [PATCH] Added move_con_map functionality. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1583 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zm_actions.php | 116 +++++++++++++++++++++++++++++++++ web/zm_html_view_watchfeed.php | 18 ++++- 2 files changed, 131 insertions(+), 3 deletions(-) diff --git a/web/zm_actions.php b/web/zm_actions.php index 974a83e52..645548b4a 100644 --- a/web/zm_actions.php +++ b/web/zm_actions.php @@ -401,6 +401,122 @@ if ( isset($action) ) } } } + elseif ( $control == "move_con_map" ) + { + $x = deScale( $x, $scale ); + $y = deScale( $y, $scale ); + + $half_width = $monitor['Width'] / 2; + $half_height = $monitor['Height'] / 2; + $x_factor = ($x - $half_width)/$half_width; + $y_factor = ($y - $half_height)/$half_height; + + switch ( $monitor['Orientation'] ) + { + case '90' : + $temp_y_factor = $y; + $y_factor = -$x_factor; + $x_factor = $temp_y_factor; + break; + case '180' : + $x_factor = -$x_factor; + $y_factor = -$y_factor; + break; + case '270' : + $temp_x_factor = $x; + $x_factor = -$y_factor; + $y_factor = $tenp_x_factor; + break; + case 'hori' : + $x_factor = -$x_factor; + break; + case 'vert' : + $y_factor = -$y_factor; + break; + } + + $turbo = 0.9; // Threshold for turbo speed + $blind = 0.1; // Threshold for blind spot + + $pan_control = ''; + $tilt_control = ''; + if ( $x_factor > $blind ) + { + $pan_control = 'right'; + } + elseif ( $x_factor < -$blind ) + { + $pan_control = 'left'; + } + if ( $y_factor > $blind ) + { + $tilt_control = 'down'; + } + elseif ( $y_factor < -$blind ) + { + $tilt_control = 'up'; + } + + $dirn = $tilt_control.$pan_control; + if ( !$dirn ) + { + // No command, probably in blind spot in middle + $control = 'move_stop'; + } + else + { + $control = 'move_con_'.$dirn; + $x_factor = abs($x_factor); + $y_factor = abs($y_factor); + + if ( $monitor['HasPanSpeed'] && $x_factor ) + { + if ( $monitor['HasTurboPan'] ) + { + if ( $x_factor >= $turbo ) + { + $pan_speed = $monitor['TurboPanSpeed']; + } + else + { + $x_factor = $x_factor/$turbo; + $pan_speed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$x_factor))); + } + } + else + { + $pan_speed = intval(round($monitor['MinPanSpeed']+(($monitor['MaxPanSpeed']-$monitor['MinPanSpeed'])*$x_factor))); + } + } + if ( $monitor['HasTiltSpeed'] && $y_factor ) + { + if ( $monitor['HasTurboTilt'] ) + { + if ( $y_factor >= $turbo ) + { + $tilt_speed = $monitor['TurboTiltSpeed']; + } + else + { + $y_factor = $y_factor/$turbo; + $tilt_speed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$y_factor))); + } + } + else + { + $tilt_speed = intval(round($monitor['MinTiltSpeed']+(($monitor['MaxTiltSpeed']-$monitor['MinTiltSpeed'])*$y_factor))); + } + } + if ( preg_match( '/(left|right)$/', $dirn ) ) + { + $ctrl_command .= " --panspeed=".$pan_speed; + } + if ( preg_match( '/^(up|down)/', $dirn ) ) + { + $ctrl_command .= " --tiltspeed=".$tilt_speed; + } + } + } else { $slow = 0.25; // Threshold for slow speed/timeouts diff --git a/web/zm_html_view_watchfeed.php b/web/zm_html_view_watchfeed.php index b750d3084..43a97307c 100644 --- a/web/zm_html_view_watchfeed.php +++ b/web/zm_html_view_watchfeed.php @@ -32,7 +32,7 @@ if ( empty($mode) ) $mode = "still"; } -$sql = "select M.*,C.CanMoveMap,C.CanMoveRel from Monitors as M left join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'"; +$sql = "select M.*,C.CanMoveMap,C.CanMoveRel,C.CanMoveCon from Monitors as M left join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'"; $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); @@ -140,7 +140,7 @@ showcontrols="0"> $stream_src = getStreamSrc( array( "mode=jpeg", "monitor=".$mid, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) ); if ( canStreamNative() ) { - if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel']) ) + if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel'] || $monitor['CanMoveCon']) ) { ?>
@@ -158,6 +158,12 @@ showcontrols="0"> { ?> + + @@ -183,7 +189,7 @@ showcontrols="0"> } else { - if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel']) ) + if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel'] || $monitor['CanMoveCon']) ) { ?> @@ -201,6 +207,12 @@ else { ?> + +