|
/**
* 布控球控制方法
* 监听控制按钮的OnTouchListener
*
* 上: event.getAction() == MotionEvent.ACTION_DOWN ptzControl(0, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_UP, 8, 0);
* event.getAction() == MotionEvent.ACTION_UP ptzControl(1, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_UP, 8, 0);
*
* 下: event.getAction() == MotionEvent.ACTION_DOWN ptzControl(0, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_DOWN, 8, 0);
* event.getAction() == MotionEvent.ACTION_UP ptzControl(1, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_DOWN, 8, 0);
*
* 左: event.getAction() == MotionEvent.ACTION_DOWN ptzControl(0, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_LEFT, 8, 0);
* event.getAction() == MotionEvent.ACTION_UP ptzControl(1, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_LEFT, 8, 0);
*
* 右: event.getAction() == MotionEvent.ACTION_DOWN ptzControl(0, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_RIGHT, 8, 0);
* event.getAction() == MotionEvent.ACTION_UP ptzControl(1, BVCU_PTZ_Command.BVCU_PTZ_COMMAND_RIGHT, 8, 0);
*
* @param bStop 开始/结束
* @param iPTZCommand 移动命令
* @param horizontalSpeed 速度
* @param verticalSpeed 速度
*/
private void ptzControl(int bStop, int iPTZCommand, int horizontalSpeed, int verticalSpeed) {
BVCU_Command command = new BVCU_Command();
command.iMethod = BVCU_Method.BVCU_METHOD_CONTROL;
command.iSubMethod = BVCU_SubMethod.BVCU_SUBMETHOD_PU_PTZCONTROL;
command.szTargetID = deviceID; // PU_ID
command.iTargetIndex = 0; //默认填0即可
command.stMsgContent = new BVCU_CmdMsgContent();
BVCU_PUCFG_PTZControl ptz = new BVCU_PUCFG_PTZControl();
ptz.iPTZCommand = iPTZCommand;
ptz.bStop = bStop;
ptz.iParam1 = verticalSpeed;
ptz.iParam2 = horizontalSpeed;
ptz.iParam3 = 0;
command.stMsgContent.pData = ptz;
command.stMsgContent.iDataCount = 1;
int token = BVCU.getSDK().sendCmd(command);
} |
|