// Copyright (c) 2006 Industrial Video & Control Co. LLC. All rights reserved. // request relay server commands function requestPointClick(feedId, width, height, pointX, pointY) { requestCommandAsync(createPointClickCommand(feedId, width, height, pointX, pointY)); } function requestPanLeft(feedId, dist, unit) { requestCommandAsync(createPanLeftCommand(feedId, dist, unit)); } function requestPanRight(feedId, dist, unit) { requestCommandAsync(createPanRightCommand(feedId, dist, unit)); } function requestTiltUp(feedId, dist, unit) { requestCommandAsync(createTiltUpCommand(feedId, dist, unit)); } function requestTiltDown(feedId, dist, unit) { requestCommandAsync(createTiltDownCommand(feedId, dist, unit)); } function requestZoom(feedId, zoomLevel) { requestCommandAsync(createZoomCommand(feedId, zoomLevel)); } function requestFocus(feedId, focusValue) { requestCommandAsync(createFocusCommand(feedId, focusValue)); } function requestIris(feedId, irisValue) { requestCommandAsync(createIrisCommand(feedId, irisValue)); } function requestOsd(feedId, osdValue) { requestCommandAsync(createOsdCommand(feedId, osdValue)); } function requestPreset(feedId, presetNum) { requestCommandAsync(createPresetCommand(feedId, presetNum)); } function requestPanPreset(feedId, panoramaNum, width, height, posX, posY) { requestCommandAsync(createPanPresetCommand(feedId, panoramaNum, width, height, posX, posY)); } function requestGenericCommand(feedId, command, mode) { requestCommandAsync(createGenericCommand(feedId, command, mode)); } function requestContinuousMoveCommand(feedId, paramName, paramValue) { requestCommandAsync(createContinuousMoveCommand(feedId, paramName, paramValue)); } function requestFrameBufferSizeSeconds(feedId) { return requestCommandSync(createFrameBufferSizeSecondsCommand(feedId)); } function requestCacheInventory(feedId, includeSnapshots, includeClipFiles, startTimeStr, endTimeStr) { return requestCommandSync(createCacheInventoryCommand(feedId, includeSnapshots, includeClipFiles, startTimeStr, endTimeStr)); } function requestCommandAsync(command) { var oXmlHttp = createHttpRequest(command, true); if (oXmlHttp) { oXmlHttp.send(null); } return oXmlHttp; } function requestCommandSync(command) { var response = null; var oXmlHttp = createHttpRequest(command, false); if (oXmlHttp) { oXmlHttp.send(null); if (oXmlHttp.status == 200) response = oXmlHttp.responseText; } return response; } function createHttpRequest(command, async) { var oXmlHttp = createRequest(); if (oXmlHttp != null) { oXmlHttp.open("get", command, async); oXmlHttp.setRequestHeader("Cache-Control", "no-cache"); oXmlHttp.setRequestHeader("If-Modified-Since", "Thur, 1 Jan 1970 00:00:00 GMT"); } return oXmlHttp; } function createPointClickCommand(feedId, width, height, pointX, pointY) { return ("/control/" + feedId + "/cmd=point&iheight=" + height + "&iwidth=" + width + "?" + pointX + "," + pointY); } function createPanLeftCommand(feedId, dist, unit) { return createDirectionalControlCommand(feedId, dist, unit, "l"); } function createPanRightCommand(feedId, dist, unit) { return createDirectionalControlCommand(feedId, dist, unit, "r"); } function createTiltUpCommand(feedId, dist, unit) { return createDirectionalControlCommand(feedId, dist, unit, "u"); } function createTiltDownCommand(feedId, dist, unit) { return createDirectionalControlCommand(feedId, dist, unit, "d"); } function createPresetCommand(feedId, presetNum) { return ("/control/" + feedId + "/cmd=dir&dir=p&presetnumber=" + presetNum); } function createZoomCommand(feedId, zoomLevel) { return createDirectionalControlCommand(feedId, zoomLevel, "", "z"); } function createFocusCommand(feedId, focusValue) { return ("/control/" + feedId + "/cmd=video&function=focus&focusvalue=" + focusValue); } function createIrisCommand(feedId, irisValue) { return ("/control/" + feedId + "/cmd=video&function=iris&irisValue=" + irisValue); } function createOsdCommand(feedId, osdValue) { return ("/control/" + feedId + "/cmd=video&function=osd&osdValue=" + osdValue); } function createPanPresetCommand(feedId, panoramaNum, width, height, posX, posY) { return ("/control/" + feedId + "/cmd=pan&panpresetnumber=" + panoramaNum + "&iheight=" + height + "&iwidth=" + width + "?" + posX + "," + posY); } function createGenericCommand(feedId, command, mode) { return ("/control/" + feedId + "/cmd=gen&gencommand=" + command + "&genmode=" + mode); } function createDirectionalControlCommand(feedId, dist, unit, dir) { var command = "/control/" + feedId + "/cmd=dir&dir=" + dir + "&dist=" + dist; if (unit.length > 0) command += "&unit=" + unit; return command; } function createContinuousMoveCommand(feedId, paramName, paramValue) { return ("/control/" + feedId + "/cmd=c&" + paramName + "=" + paramValue); } function createFrameBufferSizeSecondsCommand(feedId) { return ("/info/" + feedId + "/getvar&framebuffersizeseconds"); } function createCacheInventoryCommand(feedId, includeSnapshots, includeClipFiles, startTimeStr, endTimeStr) { return ("/info/" + feedId + "/getvar&ivccacheinventory&snapshotfiles=" + includeSnapshots + "&clipfiles=" + includeClipFiles + "&starttime=" + startTimeStr + "&endtime=" + endTimeStr); }