Files
linuxcncWebWASM/run-5axis-rtcp.sh

53 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
LINUXCNC_ROOT="${REPO_ROOT}/linuxcnc"
CASE_DIR="${LINUXCNC_ROOT}/configs/sim/axis/vismach/5axis/table-rotary-tilting"
CASE_NAME="${1:-xyzac-trt.ini}"
case "${CASE_NAME}" in
xyzac-trt.ini)
DEMO_FILE="${CASE_DIR}/demos/xyzac_switchkins.ngc"
RTCP_SUBROUTINE="${CASE_DIR}/remap_subs/helix_ac.ngc"
;;
xyzbc-trt.ini)
DEMO_FILE="${CASE_DIR}/demos/xyzbc_switchkins.ngc"
RTCP_SUBROUTINE="${CASE_DIR}/remap_subs/helix_bc.ngc"
;;
*)
printf 'case must be xyzac-trt.ini or xyzbc-trt.ini\n' >&2
exit 2
;;
esac
CASE_INI="${CASE_DIR}/${CASE_NAME}"
if [[ ! -f "${CASE_INI}" ]]; then
printf '5-axis RTCP configuration not found: %s\n' "${CASE_INI}" >&2
exit 1
fi
if [[ ! -f "${DEMO_FILE}" ]]; then
printf '5-axis RTCP demo program not found: %s\n' "${DEMO_FILE}" >&2
exit 1
fi
if [[ ! -f "${RTCP_SUBROUTINE}" ]]; then
printf '5-axis RTCP subroutine not found: %s\n' "${RTCP_SUBROUTINE}" >&2
exit 1
fi
if ! grep -Eq '^[[:space:]]*M428([[:space:];]|$)' "${RTCP_SUBROUTINE}"; then
printf 'RTCP switch M428 not found in: %s\n' "${RTCP_SUBROUTINE}" >&2
exit 1
fi
LINUXCNC_LAUNCHER="${LINUXCNC_ROOT}/scripts/linuxcnc"
if [[ ! -x "${LINUXCNC_LAUNCHER}" ]]; then
printf 'LinuxCNC source launcher not found: %s\n' "${LINUXCNC_LAUNCHER}" >&2
exit 1
fi
cd "${LINUXCNC_ROOT}"
printf 'Starting 5-axis RTCP case: %s\n' "${CASE_INI}"
printf 'Demo program: %s\n' "${DEMO_FILE}"
printf 'RTCP subroutine: %s\n' "${RTCP_SUBROUTINE}"
# The demo subroutine uses M428 to switch switchkins into XYZAC/XYZBC TCP mode.
exec "${LINUXCNC_ROOT}/scripts/rip-environment" linuxcnc -r "${CASE_INI}"