36 lines
2.6 KiB
Python
36 lines
2.6 KiB
Python
from pathlib import Path
|
|
import sys,time,json
|
|
sys.path.insert(0,'D:/YMR/AMI/tmp')
|
|
import migrate_hmi as h
|
|
R=Path('D:/YMR/AMI');O=R/'docs/evidence/2026-10-07/small-as-status'
|
|
large=(R/'scripts/hmi/TJC8048X370_011/dash-status-render.txt').read_text(encoding='utf-8')
|
|
ascode=large[large.index('if(as_state!=shown_as)'):].replace('330,379,174,53,4,','194,215,108,30,0,').replace('Manual Driving','有人驾驶')
|
|
renderer=(R/'scripts/hmi/dash-status-render.txt').read_text(encoding='utf-8')
|
|
if 'if(as_state!=shown_as)' not in renderer:renderer=renderer.rstrip()+'\n'+ascode
|
|
(R/'scripts/hmi/dash-status-render.txt').write_text(renderer,encoding='utf-8')
|
|
post='shown_task=-1\nshown_lock=-1\nshown_ebs=-1\nshown_as=-1\n'+renderer
|
|
(R/'scripts/hmi/dash-postinit.txt').write_text(post,encoding='utf-8')
|
|
h.N.set_focus();h.page(0);h.select('sd(文本)')
|
|
(O/'lock-before.json').write_text(json.dumps(h.props(),ensure_ascii=False,indent=2),encoding='utf-8')
|
|
for k,v in [('x',126),('w',66)]:
|
|
h.G.element_info.element.SetFocus();h.pg.hotkey('ctrl','end');time.sleep(.4);h.refresh_cells()
|
|
cell=h.CELL_MAP[k];r=cell.rectangle();h.pg.doubleClick((r.left+r.right)//2,(r.top+r.bottom)//2,interval=.1);time.sleep(.4);h.pg.hotkey('ctrl','a');h.pg.write(str(v));h.pg.press('enter');time.sleep(.2)
|
|
h.refresh_cells();assert h.props()[k]==str(v),(k,h.props())
|
|
(O/'lock-after.json').write_text(json.dumps(h.props(),ensure_ascii=False,indent=2),encoding='utf-8')
|
|
for item,tab,code in [('dash(页面)',1550,post),('tm0(定时器)',1330,renderer)]:
|
|
h.select(item);actual=h.event_text(tab,code);assert ''.join(actual.split())==''.join(code.split())
|
|
h.W.child_window(title='Program.s',control_type='Button').click_input();time.sleep(.3)
|
|
code=(R/'scripts/hmi/Program.s').read_text(encoding='utf-8')
|
|
h.pg.click(1100,600);h.pg.hotkey('ctrl','a');h.clipset(code.replace('\n','\r\n'));h.pg.hotkey('ctrl','v');time.sleep(.5)
|
|
h.pg.hotkey('ctrl','a');h.clipset('__PENDING__');h.pg.hotkey('ctrl','c');time.sleep(.3)
|
|
h.win32clipboard.OpenClipboard()
|
|
try:actual=h.win32clipboard.GetClipboardData(h.win32clipboard.CF_UNICODETEXT)
|
|
finally:h.win32clipboard.CloseClipboard()
|
|
assert ''.join(actual.split())==''.join(code.split())
|
|
h.W.child_window(title='保存',control_type='Button').click_input();time.sleep(.5)
|
|
h.W.child_window(title='编译',control_type='Button').click_input();time.sleep(3)
|
|
logs='\n'.join(c.window_text() for c in h.N.descendants() if 'RichEdit' in c.class_name() and '编译' in c.window_text())
|
|
(O/'compile.log').write_text(logs,encoding='utf-8');print(logs[-1800:])
|
|
h.W.child_window(title='调试',control_type='Button').click_input();time.sleep(4)
|
|
h.pg.screenshot().save(str(R/'tmp/small-simulator.png'))
|