Skip to content

Commit

Permalink
fix blocking status during mdi
Browse files Browse the repository at this point in the history
Signed-off-by: John Thornton <dev@gnipsel.com>
  • Loading branch information
jethornton committed Feb 8, 2024
1 parent d8d5d23 commit c26ab00
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jet/src/jet
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class jet_gui(QMainWindow):

size = self.inifile.find('DISPLAY', 'SIZE') or False

#self.c = None
self.mdi_command = False

connections.connect(self)
startup.set_labels(self)
Expand Down
3 changes: 2 additions & 1 deletion jet/src/libjet/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def run_mdi(parent, cmd=''):
mdi_command = cmd
else:
mdi_command = parent.mdi_command_le.text()
parent.mdi_command = mdi_command

if mdi_command:
if parent.status.task_state == emc.STATE_ON:
Expand All @@ -202,12 +203,12 @@ def run_mdi(parent, cmd=''):
parent.command.wait_complete()
parent.pause_pb.setEnabled(True)
parent.command.mdi(mdi_command)
'''
parent.status.poll()
while parent.status.state == parent.emc.RCS_EXEC:
parent.status.poll()
if parent.status.state == parent.emc.RCS_DONE:
print('done')
'''
if parent.mdi_history_lw_exists:
parent.mdi_history_lw.addItem(mdi_command)
parent.mdi_command_le.setText('')
Expand Down
7 changes: 7 additions & 0 deletions jet/src/libjet/status.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@

from PyQt6.QtGui import QTextCursor, QTextBlockFormat, QColor
from PyQt6.QtWidgets import QTextEdit, QWidget

from libjet import utilities

def update(parent):
parent.status.poll()

if parent.mdi_command and parent.status.state == parent.emc.RCS_DONE:
utilities.update_mdi(parent)

task_mode = {1: 'MANUAL', 2: 'AUTO', 3: 'MDI'}
if parent.status_lb_exists:
parent.status_lb.setText(task_mode[parent.status.task_mode])
Expand Down
20 changes: 20 additions & 0 deletions jet/src/libjet/utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os

from PyQt6.QtWidgets import QLabel

from libjet import utilities

def add_mdi(parent):
parent.mdi_command_le.setText(f'{parent.mdi_history_lw.currentItem().text()}')

Expand All @@ -11,5 +14,22 @@ def jog_slider(parent):
def clear_mdi_history(parent):
parent.mdi_history_lw.clear()

def update_mdi(parent):
if parent.mdi_history_lw_exists:
parent.mdi_history_lw.addItem(parent.mdi_command)
parent.mdi_command_le.setText('')
if parent.mdi_history_lw_exists:
path = os.path.dirname(parent.status.ini_filename)
mdi_file = os.path.join(path, 'mdi_history.txt')
mdi_codes = []
for index in range(parent.mdi_history_lw.count()):
mdi_codes.append(parent.mdi_history_lw.item(index).text())
with open(mdi_file, 'w') as f:
f.write('\n'.join(mdi_codes))
parent.mdi_command = False
parent.command.mode(parent.emc.MODE_MANUAL)
parent.command.wait_complete()




0 comments on commit c26ab00

Please sign in to comment.