caps = $caps; } public function __call($fn, $args) { return isset($this->caps[$fn]) ? $this->caps[$fn] : 0; } } class OptMonitor { private $control; private $orientation; private $autostop; public function __construct($control, $orientation = 'ROTATE_0', $autostop = 0) { $this->control = $control; $this->orientation = $orientation; $this->autostop = $autostop; } public function Id() { return 1; } public function Control() { return $this->control; } public function Orientation() { return $this->orientation; } public function AutoStopTimeout() { return $this->autostop; } } function command_for($monitor, array $request) { $_REQUEST = $request; return buildControlCommand($monitor); } // moveStop on release of a pan/tilt button $ctrl = new OptControl(array('CanMoveCon' => 1)); foreach (array('ROTATE_0', 'ROTATE_90', 'ROTATE_180', 'ROTATE_270', 'FLIP_HORI', 'FLIP_VERT') as $orientation) { $cmd = command_for(new OptMonitor($ctrl, $orientation), array('control' => 'moveStop', 'xge' => 50, 'yge' => 50)); check("moveStop with xge/yge is unchanged on $orientation", $cmd, ' --command=moveStop'); } // zoom and focus without a speed range still auto stop $noSpeed = new OptControl(array('CanZoomCon' => 1, 'CanFocusCon' => 1, 'HasZoomSpeed' => 0, 'HasFocusSpeed' => 0)); $cmd = command_for(new OptMonitor($noSpeed, 'ROTATE_0', 2), array('control' => 'zoomConTele', 'yge' => 50)); check('zoomConTele without a zoom speed gets --autostop', strpos($cmd, '--autostop') !== false, true); $cmd = command_for(new OptMonitor($noSpeed, 'ROTATE_0', 2), array('control' => 'focusConNear', 'yge' => 50)); check('focusConNear without a focus speed gets --autostop', strpos($cmd, '--autostop') !== false, true); $cmd = command_for(new OptMonitor($noSpeed, 'ROTATE_0', 0), array('control' => 'zoomConTele', 'yge' => 50)); check('no auto stop timeout, no --autostop', strpos($cmd, '--autostop'), false); $speed = new OptControl(array('HasZoomSpeed' => 1, 'MinZoomSpeed' => 1, 'MaxZoomSpeed' => 10)); $cmd = command_for(new OptMonitor($speed, 'ROTATE_0', 2), array('control' => 'zoomConTele', 'yge' => 100)); check('fast zoom with a speed range is not auto stopped', strpos($cmd, '--autostop'), false); $cmd = command_for(new OptMonitor($speed, 'ROTATE_0', 2), array('control' => 'zoomConTele', 'yge' => 10)); check('slow zoom with a speed range is auto stopped', strpos($cmd, '--autostop') !== false, true); // relative step is not scaled by the turbo adjustment $turbo = new OptControl(array( 'HasPanSpeed' => 1, 'MinPanSpeed' => 1, 'MaxPanSpeed' => 10, 'HasTurboPan' => 1, 'TurboPanSpeed' => 20, 'MinPanStep' => 0, 'MaxPanStep' => 100, 'HasTiltSpeed' => 1, 'MinTiltSpeed' => 1, 'MaxTiltSpeed' => 10, 'HasTurboTilt' => 1, 'TurboTiltSpeed' => 20, 'MinTiltStep' => 0, 'MaxTiltStep' => 100, )); $cmd = command_for(new OptMonitor($turbo), array('control' => 'moveRelRight', 'xge' => 50, 'yge' => 0)); check('pan step at half way is half the step range with turbo pan', preg_match('/--panstep=(\d+)/', $cmd, $m) ? $m[1] : null, '50'); check('pan speed still uses the turbo scale', preg_match('/--panspeed=(\d+)/', $cmd, $m) ? $m[1] : null, '6'); $cmd = command_for(new OptMonitor($turbo), array('control' => 'moveRelDown', 'xge' => 0, 'yge' => 50)); check('tilt step at half way is half the step range with turbo tilt', preg_match('/--tiltstep=(\d+)/', $cmd, $m) ? $m[1] : null, '50'); echo "\n$passes passed, $failures failed\n"; exit($failures ? 1 : 0);