Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b521beb3c3 |
@@ -226,6 +226,10 @@ def build_ui(node: CtrlGuiNode) -> None:
|
||||
|
||||
# Shared variables for arm control
|
||||
arm_inputs = {}
|
||||
# Auto Run timer/button state
|
||||
auto_run_timer = None
|
||||
auto_running = False
|
||||
auto_run_btn = None
|
||||
|
||||
with ui.row():
|
||||
|
||||
@@ -284,7 +288,7 @@ def build_ui(node: CtrlGuiNode) -> None:
|
||||
def rebuild_in() -> None:
|
||||
try:
|
||||
node.file_logger.info('Running rebuild_now...')
|
||||
rebuild_now("Trigger", "bt_carry_boxes_sch1", "")
|
||||
rebuild_now("Trigger", "bt_carry_boxes_sch2", "")
|
||||
except Exception as e:
|
||||
node.file_logger.error(f'Failed to trigger rebuild: {str(e)}')
|
||||
|
||||
@@ -297,13 +301,67 @@ def build_ui(node: CtrlGuiNode) -> None:
|
||||
def rebuild_out() -> None:
|
||||
try:
|
||||
node.file_logger.info('Running rebuild_now...')
|
||||
rebuild_now("Trigger", "bt_carry_boxes_sch2", "")
|
||||
rebuild_now("Trigger", "bt_carry_boxes_sch1", "")
|
||||
except Exception as e:
|
||||
node.file_logger.error(f'Failed to trigger rebuild: {str(e)}')
|
||||
|
||||
ui.element().style('height: 40px')
|
||||
ui.button('Stock Out', on_click=lambda: show_confirm_dialog('Confirm Switch Schedule?', rebuild_out)).classes('self-end')
|
||||
|
||||
with ui.column():
|
||||
with ui.row():
|
||||
pass
|
||||
|
||||
def toggle_auto_run() -> None:
|
||||
nonlocal auto_run_timer, auto_running, auto_run_btn
|
||||
try:
|
||||
if not auto_running:
|
||||
# start timer
|
||||
if auto_run_timer is None:
|
||||
def tick():
|
||||
print('auto_run_timer tick')
|
||||
try:
|
||||
if node.last_work_info.working_state != 'Working':
|
||||
print('working_state is not Working, ' + str(node.last_work_info.task[0]) + ", " + str(node.last_work_info.task[2]))
|
||||
if node.last_work_info.task[0] == 'StockIn' and node.last_work_info.task[2] == "None":
|
||||
rebuild_now("Trigger", "bt_carry_boxes_sch1", "")
|
||||
print('1-Triggered StockOut schedule')
|
||||
elif node.last_work_info.task[0] == 'StockOut' and node.last_work_info.task[2] == "None":
|
||||
rebuild_now("Trigger", "bt_carry_boxes_sch2", "")
|
||||
print('2-Triggered StockIn schedule')
|
||||
elif node.last_work_info.task[0] == 'None' and node.last_work_info.task[2] == "None":
|
||||
rebuild_now("Trigger", "bt_carry_boxes_sch2", "")
|
||||
print('3-Triggered StockIn schedule')
|
||||
except Exception as e:
|
||||
print("error: " + str(e))
|
||||
pass
|
||||
auto_run_timer = ui.timer(10.0, tick, active=True)
|
||||
else:
|
||||
auto_run_timer.active = True
|
||||
auto_running = True
|
||||
if auto_run_btn:
|
||||
auto_run_btn.set_text('STOP')
|
||||
node.file_logger.info('Auto timer started')
|
||||
else:
|
||||
# stop timer
|
||||
if auto_run_timer is not None:
|
||||
auto_run_timer.active = False
|
||||
auto_running = False
|
||||
if auto_run_btn:
|
||||
auto_run_btn.set_text('Auto Run')
|
||||
node.file_logger.info('Auto timer stopped')
|
||||
except Exception as e:
|
||||
node.file_logger.error(f'Auto run toggle failed: {str(e)}')
|
||||
ui.notify(f'Auto run failed: {str(e)}', color='negative')
|
||||
|
||||
def on_auto_run_click():
|
||||
# dynamic confirm message depending on current state
|
||||
msg = 'Confirm Stop Auto Run?' if auto_running else 'Confirm Start Auto Run?'
|
||||
show_confirm_dialog(msg, toggle_auto_run)
|
||||
|
||||
ui.element().style('height: 40px')
|
||||
auto_run_btn = ui.button('Auto Run', on_click=on_auto_run_click).classes('self-end')
|
||||
|
||||
#move home
|
||||
with ui.column():
|
||||
with ui.row():
|
||||
|
||||
Reference in New Issue
Block a user