Object.defineProperty(exports, "__esModule", { value: true });
var visca_over_ip_1 = require("visca-over-ip");
module.exports = function (api) {
    //Register a action
    api.registerAction('home', 'Go to home position', require('./actions/home'));
    api.registerAction('reset', 'Reset/Calibrate', require('./actions/reset'));
    api.registerAction('gainDown', 'Gain down', require('./actions/gainDown'));
    api.registerAction('gainUp', 'Gain up', require('./actions/gainUp'));
    api.registerAction('gainReset', 'Gain reset', require('./actions/gainReset'));
    api.registerAction('irisDown', 'Iris down', require('./actions/irisDown'));
    api.registerAction('irisUp', 'Iris up', require('./actions/irisUp'));
    api.registerAction('irisReset', 'Iris reset', require('./actions/irisReset'));
    api.registerAction('shutterDown', 'Shutter down', require('./actions/shutterDown'));
    api.registerAction('shutterUp', 'Shutter up', require('./actions/shutterUp'));
    api.registerAction('shutterReset', 'Shutter reset', require('./actions/shutterReset'));
    api.registerAction('zoomIn', 'Zoom in', require('./actions/zoomIn'));
    api.registerAction('zoomOut', 'Zoom out', require('./actions/zoomOut'));
    api.registerAction('zoomStop', 'Zoom stop', require('./actions/zoomStop'));
    api.registerAction('presetRecall', 'Recall preset', require('./actions/presetRecall'));
    api.registerAction('presetSet', 'Set preset', require('./actions/presetSet'));
    api.registerAction('presetReset', 'Reset preset', require('./actions/presetReset'));
    api.registerAction('panLeft', 'Pan left', require('./actions/panLeft'));
    api.registerAction('panRight', 'Pan right', require('./actions/panRight'));
    api.registerAction('tiltUp', 'Tilt up', require('./actions/tiltUp'));
    api.registerAction('tiltDown', 'Tilt down', require('./actions/tiltDown'));
    api.registerAction('panTiltStop', 'Stop pan/tilt', require('./actions/panTiltStop'));
    api.registerAction('panTiltSpeed', 'Set pan/tilt speed', require('./actions/panTiltSpeed'));
    api.registerAction('focusFar', 'Focus far', require('./actions/focusFar'));
    api.registerAction('focusNear', 'Focus near', require('./actions/focusNear'));
    api.registerAction('focusStop', 'Focus stop', require('./actions/focusStop'));
    api.registerConnectionValidator('viscaOverIpCamera', function (ValidatorAPI) {
        if (ValidatorAPI.properties.ip != undefined) {
            if (ValidatorAPI.properties.port != undefined) {
                var camera = new visca_over_ip_1.ViscaCamera(ValidatorAPI.properties.ip, ValidatorAPI.properties.port);
                camera.on('error', console.log);
                camera.on('connected', function () {
                    var canRespond = true;
                    var responseTimeout;
                    setTimeout(function () {
                        var command = visca_over_ip_1.ViscaCommand.cameraPanTilt(0, 0);
                        command.on('ack', function () {
                            if (canRespond == true) {
                                canRespond = false;
                                ValidatorAPI.callback(true);
                                ValidatorAPI.setInstance({ internal: { pantiltSpeed: 10 }, camera: camera });
                                clearTimeout(responseTimeout);
                            }
                        });
                        responseTimeout = setTimeout(function () {
                            canRespond = false;
                            ValidatorAPI.callback(false, 'Timeout reached');
                        }, 10000);
                        camera.sendCommand(command);
                    }, 1000);
                });
                camera.on('error', function (error) {
                    ValidatorAPI.callback(false, 'Unable to reach camera');
                    console.log(error);
                });
            }
        }
    });
};
//# sourceMappingURL=viscaOverIP.js.map