"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RisingBollardsInstallationNode = void 0;
const agv_constant_1 = require("../../entity/agv.constant");
const risingbollards_axis_util_1 = require("../../utils/risingbollards-axis.util");
class RisingBollardsInstallationNode {
  generateScript(scriptWriter) {
    const axisName = (0, risingbollards_axis_util_1.escapeLuaString)((0, risingbollards_axis_util_1.getRisingBollardsAxisName)());
    const axisInterfaceName = `${axisName}_interface`;
    scriptWriter.appendLine(`local axis_name = "${axisName}"`);
    scriptWriter.appendLine('local has_ext_axis = false');
    scriptWriter.appendLine('if app and app.api and app.api.getAxisNames then');
    scriptWriter.appendLine('  local axis_names = app.api:getAxisNames()');
    scriptWriter.appendLine('  if axis_names then');
    scriptWriter.appendLine('    for _, name in ipairs(axis_names) do');
    scriptWriter.appendLine('      if tostring(name) == axis_name then');
    scriptWriter.appendLine('        has_ext_axis = true');
    scriptWriter.appendLine('        break');
    scriptWriter.appendLine('      end');
    scriptWriter.appendLine('    end');
    scriptWriter.appendLine('  end');
    scriptWriter.appendLine('end');
    scriptWriter.appendLine('if has_ext_axis and app and app.api then');
    scriptWriter.appendLine(`  local ${axisInterfaceName} = app.api:getAxisInterface(axis_name)`);
    scriptWriter.appendLine(`  if ${axisInterfaceName} then`);
    scriptWriter.appendLine(`    ${axisInterfaceName}:setExtAxisType(${agv_constant_1.RISING_BOLLARDS_EXT_AXIS_TYPE})`);
    scriptWriter.appendLine(`    ${axisInterfaceName}:setExtAxisMaxPositionLimit(${agv_constant_1.RISING_BOLLARDS_EXT_AXIS_MAX_POSITION})`);
    scriptWriter.appendLine(`    ${axisInterfaceName}:setExtMinPositionLimit(${agv_constant_1.RISING_BOLLARDS_EXT_AXIS_MIN_POSITION})`);
    scriptWriter.appendLine(`    ${axisInterfaceName}:setExtAxisMaxVelocityLimit(${agv_constant_1.RISING_BOLLARDS_EXT_AXIS_MAX_VELOCITY})`);
    scriptWriter.appendLine(`    ${axisInterfaceName}:setExtAxisMaxAccelerationLimit(${agv_constant_1.RISING_BOLLARDS_EXT_AXIS_MAX_ACCELERATION})`);
    scriptWriter.appendLine(`    ${axisInterfaceName}:setReductionRatio(${agv_constant_1.RISING_BOLLARDS_EXT_AXIS_REDUCTION_RATIO})`);
    scriptWriter.appendLine(`    axisGroupDelete("${agv_constant_1.RISING_BOLLARDS_AXIS_GROUP_NAME}")`);
    scriptWriter.appendLine(`    axisGroupAdd("${agv_constant_1.RISING_BOLLARDS_AXIS_GROUP_NAME}", ${agv_constant_1.RISING_BOLLARDS_AXIS_GROUP_DIRECTION}, "${agv_constant_1.RISING_BOLLARDS_AXIS_GROUP_REF_FRAME}")`);
    scriptWriter.appendLine(`    axisGroupAddAxis("${agv_constant_1.RISING_BOLLARDS_AXIS_GROUP_NAME}", axis_name, axis_name, ${agv_constant_1.RISING_BOLLARDS_AXIS_GROUP_OFFSET})`);
    scriptWriter.appendLine(`    enableAxisGroup("${agv_constant_1.RISING_BOLLARDS_AXIS_GROUP_NAME}")`);
    scriptWriter.appendLine('  end');
    scriptWriter.appendLine('end');
  }
  setModel(dataModel) {}
}
exports.RisingBollardsInstallationNode = RisingBollardsInstallationNode;
//# sourceMappingURL=risingbollards-installation-node.js.map