完成L4-USER-M-PROCESS Web仿真接入
结论:L4-USER-M-PROCESS 已按 Web/virtual HAL 数控仿真主线完成接入,native LinuxCNC runtime 不再作为 Web 仿真阻塞;新增 text31.txt 接续剩余 77 个 SKIP 的 main-program promotion 复核。
This commit is contained in:
@@ -11,12 +11,23 @@ LINUXCNC_STDERR="$RUN_DIR/linuxcnc.stderr.log"
|
||||
|
||||
required_commands=(tclsh halrun halcmd linuxcnc)
|
||||
missing_commands=()
|
||||
declare -A command_paths=()
|
||||
LINUXCNC_PID=""
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "$LINUXCNC_PID" ]]; then
|
||||
kill "$LINUXCNC_PID" 2>/dev/null || true
|
||||
kill -TERM "-$LINUXCNC_PID" 2>/dev/null || kill "$LINUXCNC_PID" 2>/dev/null || true
|
||||
for _ in $(seq 1 20); do
|
||||
if ! kill -0 "$LINUXCNC_PID" 2>/dev/null; then
|
||||
wait "$LINUXCNC_PID" 2>/dev/null || true
|
||||
LINUXCNC_PID=""
|
||||
return
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
kill -KILL "-$LINUXCNC_PID" 2>/dev/null || kill -KILL "$LINUXCNC_PID" 2>/dev/null || true
|
||||
wait "$LINUXCNC_PID" 2>/dev/null || true
|
||||
LINUXCNC_PID=""
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
@@ -49,10 +60,22 @@ print_kv() {
|
||||
printf '%s=%s\n' "$1" "$2"
|
||||
}
|
||||
|
||||
existing_linuxcnc_runtime_conflicts() {
|
||||
ps -eo pid=,args= | awk '
|
||||
/linuxcncsvr -ini/ || /rtapi_app load/ {
|
||||
if ($0 !~ /awk /) {
|
||||
gsub(/^[[:space:]]+/, "", $0)
|
||||
print
|
||||
}
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
runtime_requirements=()
|
||||
for command_name in "${required_commands[@]}"; do
|
||||
path="$(command_path "$command_name")"
|
||||
if [[ -n "$path" ]]; then
|
||||
command_paths["$command_name"]="$path"
|
||||
runtime_requirements+=("$command_name:1")
|
||||
print_kv "millturn_user_m_runtime_${command_name}_path" "$path"
|
||||
else
|
||||
@@ -108,6 +131,24 @@ if [[ "${ENABLE_MILLTURN_USER_M_RUNTIME_PROBE:-0}" != "1" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
existing_runtime_conflicts="$(existing_linuxcnc_runtime_conflicts)"
|
||||
if [[ -n "$existing_runtime_conflicts" ]]; then
|
||||
print_kv millturn_user_m_runtime_ready 0
|
||||
print_kv millturn_user_m_missing_requirements "exclusive_linuxcnc_runtime"
|
||||
print_kv millturn_user_m_existing_runtime_conflicts "$(printf '%s\n' "$existing_runtime_conflicts" | paste -sd ';' -)"
|
||||
print_kv millturn_user_m_runtime_probe_status "blocked_existing_linuxcnc_runtime"
|
||||
print_kv millturn_user_m_runtime_probe_note "existing_linuxcnc_runtime_conflict_keep_user_m_process_blocked"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
HALCMD_BIN="${command_paths[halcmd]}"
|
||||
LINUXCNC_BIN="${command_paths[linuxcnc]}"
|
||||
|
||||
export PATH="$LINUXCNC_ROOT/bin:$LINUXCNC_ROOT/scripts:$LINUXCNC_ROOT/tcl:$PATH"
|
||||
export LD_LIBRARY_PATH="$LINUXCNC_ROOT/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
export PYTHONPATH="$LINUXCNC_ROOT/lib/python${PYTHONPATH:+:$PYTHONPATH}"
|
||||
export TCLLIBPATH="$LINUXCNC_ROOT/tcl${TCLLIBPATH:+ $TCLLIBPATH}"
|
||||
|
||||
mkdir -p "$RUN_DIR"
|
||||
|
||||
wait_for_hal_pin() {
|
||||
@@ -115,7 +156,7 @@ wait_for_hal_pin() {
|
||||
local limit="${MILLTURN_USER_M_RUNTIME_WAIT_SECONDS:-30}"
|
||||
local end=$((SECONDS + limit))
|
||||
while (( SECONDS < end )); do
|
||||
if halcmd getp "$pin" >/dev/null 2>&1; then
|
||||
if "$HALCMD_BIN" getp "$pin" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 0.25
|
||||
@@ -124,7 +165,7 @@ wait_for_hal_pin() {
|
||||
}
|
||||
|
||||
read_hal_pin() {
|
||||
halcmd getp "$1" 2>/dev/null | tr -d '[:space:]'
|
||||
"$HALCMD_BIN" getp "$1" 2>/dev/null | tr -d '[:space:]'
|
||||
}
|
||||
|
||||
expect_hal_pin() {
|
||||
@@ -140,9 +181,9 @@ expect_hal_pin() {
|
||||
set_switchkins_target() {
|
||||
local target="$1"
|
||||
local guard_pin="kinstype.is-$target"
|
||||
if ! halcmd setp motion.switchkins-type "$target" >/dev/null 2>&1; then
|
||||
halcmd unlinkp motion.switchkins-type >/dev/null 2>&1 || true
|
||||
halcmd setp motion.switchkins-type "$target"
|
||||
if ! "$HALCMD_BIN" setp motion.switchkins-type "$target" >/dev/null 2>&1; then
|
||||
"$HALCMD_BIN" unlinkp motion.switchkins-type >/dev/null 2>&1 || true
|
||||
"$HALCMD_BIN" setp motion.switchkins-type "$target"
|
||||
fi
|
||||
for _ in $(seq 1 40); do
|
||||
if [[ "$(read_hal_pin "$guard_pin")" =~ ^(TRUE|1)$ ]]; then
|
||||
@@ -195,7 +236,7 @@ print_kv millturn_user_m_runtime_probe_ini "$INI_FILE"
|
||||
print_kv millturn_user_m_runtime_probe_linuxcnc_stdout "$LINUXCNC_STDOUT"
|
||||
print_kv millturn_user_m_runtime_probe_linuxcnc_stderr "$LINUXCNC_STDERR"
|
||||
|
||||
linuxcnc -r "$INI_FILE" >"$LINUXCNC_STDOUT" 2>"$LINUXCNC_STDERR" &
|
||||
setsid "$LINUXCNC_BIN" -r "$INI_FILE" >"$LINUXCNC_STDOUT" 2>"$LINUXCNC_STDERR" &
|
||||
LINUXCNC_PID="$!"
|
||||
|
||||
if ! wait_for_hal_pin ini.x.min_limit || ! wait_for_hal_pin motion.switchkins-type; then
|
||||
|
||||
@@ -252,18 +252,22 @@ check_native_runtime_probe_summary_row() {
|
||||
echo "$target runtime probe unexpectedly enables execution or promotion" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! "$probe_status" =~ ^(skipped_missing_host_runtime|ready_disabled_by_default|not_implemented_full_process_guard|runtime_state_probe_passed|runtime_protocol_probe_passed|runtime_lifecycle_probe_passed)$ ]]; then
|
||||
if [[ ! "$probe_status" =~ ^(skipped_missing_host_runtime|blocked_existing_linuxcnc_runtime|ready_disabled_by_default|not_implemented_full_process_guard|runtime_state_probe_passed|runtime_protocol_probe_passed|runtime_lifecycle_probe_passed)$ ]]; then
|
||||
echo "$target runtime probe has invalid status: $probe_status" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$runtime_ready" == "0" && "$probe_status" != "skipped_missing_host_runtime" ]]; then
|
||||
if [[ "$runtime_ready" == "0" && ! "$probe_status" =~ ^(skipped_missing_host_runtime|blocked_existing_linuxcnc_runtime)$ ]]; then
|
||||
echo "$target runtime probe is not ready but did not skip: $probe_status" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$runtime_ready" == "0" && "$probe_note" != *"missing_host_runtime"* ]]; then
|
||||
if [[ "$runtime_ready" == "0" && "$probe_status" == "skipped_missing_host_runtime" && "$probe_note" != *"missing_host_runtime"* ]]; then
|
||||
echo "$target runtime probe missing-runtime note drift: $probe_note" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$runtime_ready" == "0" && "$probe_status" == "blocked_existing_linuxcnc_runtime" && "$probe_note" != *"existing_linuxcnc_runtime_conflict"* ]]; then
|
||||
echo "$target runtime probe existing-runtime-conflict note drift: $probe_note" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$runtime_ready" == "1" && "$missing_requirements" != "-" ]]; then
|
||||
echo "$target runtime probe is ready but lists missing requirements: $missing_requirements" >&2
|
||||
exit 1
|
||||
@@ -654,7 +658,7 @@ if grep -Fq "millturn_user_m_runtime_ready=1" "$MILLTURN_USER_M_RUNTIME_STDOUT";
|
||||
fi
|
||||
else
|
||||
grep -Fq "millturn_user_m_runtime_ready=0" "$MILLTURN_USER_M_RUNTIME_STDOUT"
|
||||
grep -Fq "millturn_user_m_runtime_probe_status=skipped_missing_host_runtime" \
|
||||
grep -Eq "millturn_user_m_runtime_probe_status=(skipped_missing_host_runtime|blocked_existing_linuxcnc_runtime)" \
|
||||
"$MILLTURN_USER_M_RUNTIME_STDOUT"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user