Added move_con_map functionality.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1583 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-11-10 12:04:37 +00:00
parent 062f90acac
commit a96ccd71f7
2 changed files with 131 additions and 3 deletions

View File

@ -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 else
{ {
$slow = 0.25; // Threshold for slow speed/timeouts $slow = 0.25; // Threshold for slow speed/timeouts

View File

@ -32,7 +32,7 @@ if ( empty($mode) )
$mode = "still"; $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 ); $result = mysql_query( $sql );
if ( !$result ) if ( !$result )
die( mysql_error() ); die( mysql_error() );
@ -140,7 +140,7 @@ showcontrols="0">
$stream_src = getStreamSrc( array( "mode=jpeg", "monitor=".$mid, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) ); $stream_src = getStreamSrc( array( "mode=jpeg", "monitor=".$mid, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) );
if ( canStreamNative() ) if ( canStreamNative() )
{ {
if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel']) ) if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel'] || $monitor['CanMoveCon']) )
{ {
?> ?>
<form name="ctrl_form" method="get" action="<?= $PHP_SELF ?>" target="ControlSink<?= $mid ?>"> <form name="ctrl_form" method="get" action="<?= $PHP_SELF ?>" target="ControlSink<?= $mid ?>">
@ -158,6 +158,12 @@ showcontrols="0">
{ {
?> ?>
<input type="hidden" name="control" value="move_pseudo_map"> <input type="hidden" name="control" value="move_pseudo_map">
<?php
}
elseif ( $monitor['CanMoveCon'] )
{
?>
<input type="hidden" name="control" value="move_con_map">
<?php <?php
} }
?> ?>
@ -183,7 +189,7 @@ showcontrols="0">
} }
else else
{ {
if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel']) ) if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel'] || $monitor['CanMoveCon']) )
{ {
?> ?>
<form name="ctrl_form" method="get" action="<?= $PHP_SELF ?>" target="ControlSink<?= $mid ?>"> <form name="ctrl_form" method="get" action="<?= $PHP_SELF ?>" target="ControlSink<?= $mid ?>">
@ -201,6 +207,12 @@ else
{ {
?> ?>
<input type="hidden" name="control" value="move_pseudo_map"> <input type="hidden" name="control" value="move_pseudo_map">
<?php
}
elseif ( $monitor['CanMoveCon'] )
{
?>
<input type="hidden" name="control" value="move_con_map">
<?php <?php
} }
?> ?>