ethercat-linux/uia_open_rt.py
Tony Cao 3a26aea082 2kHz spin-lock mode: RTT halved to 2ms, per-byte XOR proof at 500us cycle
- ticker: --spin mode polls FPRD until payload changes (phase-locks
  processing to TwinCAT frame arrival instead of free-running ticker),
  timeout at 1.5 periods keeps loop alive on master stop
- verified: 238k cycles, 0 errors, exec=245us (FPWR-bound),
  TwinCAT PLC task confirmed at 2000.8 Hz (all three tasks 0.5ms;
  base tick was already 50us - no base-time change needed)
- docs: 500us latency plan; scripts: task-rate ADS probe, 2kHz deploy,
  UI automation experiments (pywinauto) for task cycle inspection
2026-07-28 00:11:34 +08:00

54 lines
1.8 KiB
Python

import sys, time
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
from pywinauto import Application
from pywinauto.mouse import double_click
app = Application(backend='uia').connect(process=1456, timeout=10)
win = app.window(title_re='.*TcXaeShell.*')
tree = win.descendants(control_type='Tree')[0]
def find_item(item, name, depth=0):
try:
item.expand(); time.sleep(0.25)
except Exception:
pass
try:
for ch in item.children():
if ch.window_text() == name:
return ch
r = find_item(ch, name, depth + 1)
if r is not None:
return r
except Exception:
pass
return None
rt = None
for root in tree.children():
rt = find_item(root, '实时')
if rt:
break
if not rt:
print('实时 node not found'); sys.exit(1)
print('found 实时, double-clicking...')
rt.iface_expand_collapse.Expand()
time.sleep(0.5)
r = rt.rectangle()
double_click(coords=(int((r.left + r.right) / 2), int((r.top + r.bottom) / 2)))
time.sleep(3)
# dump new document/dialog contents
win.set_focus()
tabs = win.descendants(control_type='TabItem')
print('tab items:', [t.window_text() for t in tabs])
combos = win.descendants(control_type='ComboBox')
print('combos:', [(c.window_text()) for c in combos])
edits = win.descendants(control_type='Edit')
print('edits:', [(e.window_text()) for e in edits][:20])
buttons = win.descendants(control_type='Button')
print('buttons:', [b.window_text() for b in buttons][:20])
# text labels containing Base
texts = win.descendants(control_type='Text')
base_related = [t.window_text() for t in texts if t.window_text() and ('Base' in t.window_text() or '' in t.window_text() or 'ms' in t.window_text() or 'CPU' in t.window_text())]
print('base-related texts:', base_related[:30])