示例#1
0
 def CALL_OWORD(self, code, time=5 ):
     log.debug('OWORD_COMMAND= {}'.format(code))
     self.ensure_mode(linuxcnc.MODE_MDI)
     self.cmd.mdi(code)
     STATUS.stat.poll()
     while STATUS.stat.exec_state == linuxcnc.EXEC_WAITING_FOR_MOTION_AND_IO or \
                     STATUS.stat.exec_state == linuxcnc.EXEC_WAITING_FOR_MOTION:
         result = self.cmd.wait_complete(time)
         if result == -1:
             log.error('Oword timeout oast () Error = # {}'.format(time, result))
             self.ABORT()
             return -1
         elif result == linuxcnc.RCS_ERROR:
             log.error('Oword RCS Error = # {}'.format(result))
             return -1
         result = linuxcnc.error_channel().poll()
         if result:
             STATUS.emit('error',result[0],result[1])
             log.error('Oword Error: {}'.format(result[1]))
             return -1
         STATUS.stat.poll()
     result = self.cmd.wait_complete(time)
     if result == -1 or result == linuxcnc.RCS_ERROR or linuxcnc.error_channel().poll():
         log.error('Oword RCS Error = # {}'.format(result))
         return -1
     result = linuxcnc.error_channel().poll()
     if result:
         STATUS.emit('error',result[0],result[1])
         log.error('Oword Error: {}'.format(result[1]))
         return -1
     log.debug('OWORD_COMMAND returns complete : {}'.format(result))
     return 0
示例#2
0
 def CALL_OWORD(self, code):
     log.debug('OWORD_COMMAND= {}'.format(code))
     self.ensure_mode(linuxcnc.MODE_MDI)
     self.cmd.mdi(code)
     STATUS.stat.poll()
     while STATUS.stat.exec_state == linuxcnc.EXEC_WAITING_FOR_MOTION_AND_IO or \
                     STATUS.stat.exec_state == linuxcnc.EXEC_WAITING_FOR_MOTION:
         result = self.cmd.wait_complete()
         if result == -1 or result == linuxcnc.RCS_ERROR :
             log.error('Oword RCS Error = # {}'.format(result))
             return -1
         result = linuxcnc.error_channel().poll()
         if result:
             STATUS.emit('error',result[0],result[1])
             log.error('Oword Error: {}'.format(result[1]))
             return -1
         STATUS.stat.poll()
     result = self.cmd.wait_complete()
     if result == -1 or result == linuxcnc.RCS_ERROR or linuxcnc.error_channel().poll():
         log.error('Oword RCS Error = # {}'.format(result))
         return -1
     result = linuxcnc.error_channel().poll()
     if result:
         STATUS.emit('error',result[0],result[1])
         log.error('Oword Error: {}'.format(result[1]))
         return -1
     log.debug('OWORD_COMMAND returns complete : {}'.format(result))
     return 0
示例#3
0
 def CALL_MDI_WAIT(self, code, time=5):
     log.debug('MDI_WAIT_COMMAND= {}, maxt = {}'.format(code, time))
     self.ensure_mode(linuxcnc.MODE_MDI)
     for l in code.split("\n"):
         log.debug('MDI_COMMAND: {}'.format(l))
         self.cmd.mdi(l)
         result = self.cmd.wait_complete(time)
         if result == -1:
             log.debug(
                 'MDI_COMMAND_WAIT timeout past {} sec. Error: {}'.format(
                     time, result))
             #STATUS.emit('MDI time out error',)
             self.ABORT()
             return -1
         elif result == linuxcnc.RCS_ERROR:
             log.debug('MDI_COMMAND_WAIT RCS error: {}'.format(
                 time, result))
             #STATUS.emit('MDI time out error',)
             return -1
         result = linuxcnc.error_channel().poll()
         if result:
             STATUS.emit('error', result[0], result[1])
             log.error('MDI_COMMAND_WAIT Error channel: {}'.format(
                 result[1]))
             return -1
     return 0
示例#4
0
    def __init__(self, parent=None):
        super(QQuickItem, self).__init__(parent)

        self._errorType = 0
        self._errorText = ""

        self.e = linuxcnc.error_channel()
示例#5
0
class _Error(QObject):

    error = linuxcnc.error_channel()

    new_error = pyqtSignal(str)
    new_message = pyqtSignal(str)

    def __init__(self, parent=None):
        super(_Error, self).__init__(parent)

    def _periodic(self):
        error = self.error.poll()
        if not error:
            return

        kind, msg = error

        if msg == "" or msg is None:
            msg = "Unknown error!"

        if kind in [linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR]:
            self.new_error.emit(msg)
            log.error(msg)
        elif kind in [
                linuxcnc.NML_TEXT, linuxcnc.OPERATOR_TEXT,
                linuxcnc.NML_DISPLAY, linuxcnc.OPERATOR_DISPLAY
        ]:
            self.new_message.emit(msg)
            log.info(msg)
        else:
            # notifications.show_error("UNKNOWN ERROR!", msg)
            log.error(msg)
示例#6
0
    def __init__(self, halcomp, builder, useropts):
        self.halcomp = halcomp
        self.builder = builder

        (directory, filename) = os.path.split(__file__)
        (basename, extension) = os.path.splitext(filename)
        self.ini_filename = os.path.join(directory, basename + '.ini')
        self.defaults = {
            IniFile.vars: {},
            IniFile.widgets:
            widget_defaults(
                select_widgets(self.builder.get_objects(),
                               hal_only=True,
                               output_only=True)),
        }
        self.ini = IniFile(self.ini_filename, self.defaults, self.builder)
        self.ini.restore_state(self)

        self.c = linuxcnc.command()
        self.e = linuxcnc.error_channel()
        self.s = linuxcnc.stat()

        self.state = hal_glib.GPin(
            halcomp.newpin('state', hal.HAL_S32, hal.HAL_IN))
        self.state.connect('value-changed', self._on_state_changed)

        self.motion_type = hal_glib.GPin(
            halcomp.newpin('motion_type', hal.HAL_S32, hal.HAL_IN))
        self.motion_type.connect('value-changed', self._on_motion_type_changed)
示例#7
0
 def __init__(self, halcomp,widgets,paths):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
     self.error = linuxcnc.error_channel()
     self.PATHS = paths
     self.IMAGE_PATH = paths.IMAGEDIR
示例#8
0
 def __init__(self, errorQueueLen=None):
    self.__gobject_init__()
    self.err = linuxcnc.error_channel()
    self.errorQueue = list()
    if errorQueueLen:
       self.queueLenMax = errorQueueLen
    else:
       self.queueLenMax = 3     
    gobject.timeout_add(100, self.pollErrors)
示例#9
0
 def __init__(self, halcomp, widgets, paths):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
     self.error = linuxcnc.error_channel()
     # connect to GStat to catch linuxcnc events
     STATUS.connect('state-on', self.on_state_on)
     STATUS.connect('state-off', self.on_state_off)
示例#10
0
    def __init__(self, parent=None):
        super(ScreenOptions, self).__init__(parent)
        self.error = linuxcnc.error_channel()
        self.catch_errors = True
        self.desktop_notify = True
        self.close_event = True
        self.play_sounds = True
        self.mchnMsg_play_sound = True
        self.mchnMsg_speak_errors = True
        self.mchnMsg_sound_type = 'ERROR'
        self.usrMsg_play_sound = True
        self.usrMsg_sound_type = 'RING'
        self.usrMsg_use_FocusOverlay = True
        self.shutdown_play_sound = True
        self.shutdown_alert_sound_type = 'READY'
        self.shutdown_exit_sound_type = 'LOGOUT'
        self.notify_start_greeting = True
        self.notify_start_title = 'Welcome'
        self.notify_start_detail = 'This option can be changed in the preference file'
        self.notify_start_timeout = 5
        self.shutdown_msg_title = 'Do you want to Shutdown now?'
        self.shutdown_msg_detail = ''
        self.user_messages = True
        self.use_pref_file = True
        self.process_tabs = True
        self.add_message_dialog = True
        self.add_close_dialog = True
        self.add_entry_dialog = False
        self.add_tool_dialog = False
        self.add_file_dialog = False
        self.add_focus_overlay = False
        self.add_versaprobe_dialog = False
        self.add_macrotab_dialog = False
        self.add_camview_dialog = False
        self.add_originoffset_dialog = False
        self.add_tooloffset_dialog = False
        self.add_calculator_dialog = False
        self.add_machinelog_dialog = False
        self.add_runFromLine_dialog = False

        self.pref_filename = '~/.qtvcp_screen_preferences'
        self._default_tab_name = ''
        self._close_color = QtGui.QColor(100, 0, 0, 150)
        self._messageDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._closeDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._entryDialogSoftkey = True
        self._entryDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._toolDialogColor = QtGui.QColor(100, 0, 0, 150)
        self._fileDialogColor = QtGui.QColor(0, 0, 100, 150)
        self._versaProbeDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._macroTabDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._camViewDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._originOffsetDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._toolOffsetDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._calculatorDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._machineLogDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._runFromLineDialogColor = QtGui.QColor(0, 0, 0, 150)
示例#11
0
 def __init__(self, halcomp, widgets, paths):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
     self.error = linuxcnc.error_channel()
     self.PATHS = paths
     self.IMAGE_PATH = paths.IMAGEDIR
     self.STYLEEDITOR = SSE(widgets, paths)
     global TOOLBAR
     TOOLBAR = ToolBarActions(path=paths)
示例#12
0
 def __init__(self, stat = None):
     gobject.GObject.__init__(self)
     self.stat = stat or linuxcnc.stat()
     self.error = linuxcnc.error_channel()
     self.cmd = linuxcnc.command()
     self.old = {}
     try:
         self.stat.poll()
         self.merge()
     except:
         pass
     gobject.timeout_add(100, self.update)
     self.current_jog_rate = 15
     self._is_all_homed = False
示例#13
0
 def CALL_MDI_WAIT(self, code):
     log.debug('MDI_WAIT_COMMAND= {}'.format(code))
     self.ensure_mode(linuxcnc.MODE_MDI)
     for l in code.split("\n"):
         self.cmd.mdi( l )
         result = self.cmd.wait_complete()
         if result == -1 or result == linuxcnc.RCS_ERROR:
             return -1
         result = linuxcnc.error_channel().poll()
         if result:
             STATUS.emit('error',result[0],result[1])
             log.error('MDI_COMMAND_WAIT Error: {}'.format(result[1]))
             return -1
     return 0
示例#14
0
    def __init__(self, command=None, status=None, error=None):
        """init docs"""
        self.command = command
        self.status = status
        self.error = error

        if not self.command:
            self.command = linuxcnc.command()

        if not self.status:
            self.status = linuxcnc.stat()

        if not self.error:
            self.error = linuxcnc.error_channel()
示例#15
0
    def __init__(self, command=None, status=None, error=None):
        """init docs"""
        self.command = command
        self.status = status
        self.error = error

        if not self.command:
            self.command = linuxcnc.command()

        if not self.status:
            self.status = linuxcnc.stat()

        if not self.error:
            self.error = linuxcnc.error_channel()
示例#16
0
 def CALL_MDI_WAIT(self, code):
     log.debug('MDI_WAIT_COMMAND= {}'.format(code))
     self.ensure_mode(linuxcnc.MODE_MDI)
     for l in code.split("\n"):
         self.cmd.mdi( l )
         result = self.cmd.wait_complete()
         if result == -1 or result == linuxcnc.RCS_ERROR:
             return -1
         result = linuxcnc.error_channel().poll()
         if result:
             STATUS.emit('error',result[0],result[1])
             log.error('MDI_COMMAND_WAIT Error: {}'.format(result[1]))
             return -1
     return 0
示例#17
0
    def __init__(self, enabled=True, mode="native", persistent=True, persistent_file='.qtpyvcp_messages.json'):
        super(Notifications, self).__init__()

        self.enabled = enabled
        self.mode = mode

        self.error_channel = linuxcnc.error_channel()

        self.messages = []
        self.notification_dispatcher = None

        self.persistant = persistent
        self.persistent_file = normalizePath(path=persistent_file,
                                             base=os.getenv('CONFIG_DIR', '~/'))
示例#18
0
    def init_linuxcnc(self):
        self.stat = linuxcnc.stat()
        self.command = linuxcnc.command()
        self.error_channel = linuxcnc.error_channel()

        self.stat.poll()
        self.serial = self.stat.echo_serial_number
        self.cmd_serial = self.serial + 1
        self.error_channel.poll()

        self.last_interp_state = self.stat.interp_state

        self.poll_task = task.LoopingCall(self.poll_linuxcnc)
        self.poll_task.start(0.1)
        self.state = 'READY'
示例#19
0
    def __init__(self, ini):
        """ Construct the class. Read values from passed .ini file"""
        self.s = linuxcnc.stat()
        self.c = linuxcnc.command()
        self.e = linuxcnc.error_channel()

        self.axes = self.set_axes()
        self.axes_with_cords = {}
        self.ini = linuxcnc.ini(ini)
        self.error_list = []

        self.max_feed_override = self.ini.find("DISPLAY", "MAX_FEED_OVERRIDE")
        self.max_spindle_override = self.ini.find("DISPLAY",
                                                  "MAX_SPINDLE_OVERRIDE")
        self.max_velocity = self.ini.find("TRAJ", "MAX_VELOCITY")
示例#20
0
 def __init__(self, parent=None):
     super(ScreenOptions, self).__init__(parent)
     self.error = linuxcnc.error_channel()
     self.catch_errors = True
     self.desktop_notify = True
     self.close_event = True
     self.play_sounds = True
     self.mchnMsg_play_sound = True
     self.usrMsg_play_sound = True
     self.usrMsg_sound_type = 'READY'
     self.usrMsg_use_FocusOverlay = True
     self.play_shutdown_sounds = True
     self.user_messages = True
     self.use_pref_file = True
     self.pref_filename = '~/.qtvcp_screen_preferences'
     self._close_color = QtGui.QColor(100, 0, 0, 150)
示例#21
0
 def __init__(self, parent=None):
     super(ScreenOptions, self).__init__(parent)
     self.error = linuxcnc.error_channel()
     self.catch_errors = True
     self.desktop_notify = True
     self.close_event = True
     self.play_sounds = True
     self.mchnMsg_play_sound = True
     self.usrMsg_play_sound = True
     self.usrMsg_sound_type = 'READY'
     self.usrMsg_use_FocusOverlay = True
     self.play_shutdown_sounds = True
     self.user_messages = True
     self.use_pref_file = True
     self.pref_filename = '~/.qtvcp_screen_preferences'
     self._close_color = QtGui.QColor(100, 0, 0, 150)
示例#22
0
    def __init__(self, enabled=True, mode="native", max_messages=5,
                 persistent=True, **kwargs):
        super(Notifications, self).__init__()

        self.enabled = enabled
        self.mode = mode
        self.max_messages = max_messages

        self.error_channel = linuxcnc.error_channel()

        self.messages = []
        self.notification_dispatcher = None

        self.persistent = persistent

        self.data_manager = getPlugin('persistent_data_manager')
示例#23
0
    def __init__(self, parent=None):
        super(ScreenOptions, self).__init__(parent)
        self.error = linuxcnc.error_channel()
        self.catch_errors = True
        self.desktop_notify = True
        self.close_event = True
        self.play_sounds = True
        self.mchnMsg_play_sound = True
        self.usrMsg_play_sound = True
        self.usrMsg_sound_type = 'READY'
        self.usrMsg_use_FocusOverlay = True
        self.play_shutdown_sounds = True
        self.notify_start_title = 'Welcome'
        self.notify_start_detail = ''
        self.notify_start_timeout = 5
        self.shutdown_msg_title = 'Do you want to Shutdown now?'
        self.shutdown_msg_detail = ''
        self.user_messages = True
        self.use_pref_file = True
        self.process_tabs = True
        self.add_message_dialog = True
        self.add_entry_dialog = False
        self.add_tool_dialog = False
        self.add_file_dialog = False
        self.add_focus_overlay = False
        self.add_versaprobe_dialog = False
        self.add_macrotab_dialog = False
        self.add_camview_dialog = False
        self.add_originoffset_dialog = False
        self.add_tooloffset_dialog = False
        self.add_calculator_dialog = False

        self.pref_filename = '~/.qtvcp_screen_preferences'
        self._default_tab_name = ''
        self._close_color = QtGui.QColor(100, 0, 0, 150)
        self._messageDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._entryDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._toolDialogColor = QtGui.QColor(100, 0, 0, 150)
        self._fileDialogColor = QtGui.QColor(0, 0, 100, 150)
        self._versaProbeDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._macroTabDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._camViewDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._originOffsetDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._toolOffsetDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._calculatorDialogColor = QtGui.QColor(0, 0, 0, 150)
示例#24
0
    def __init__(self,
                 persistent=True,
                 persistent_file='.qtpyvcp_messages.json'):
        super(Notifications, self).__init__()

        self.error_channel = linuxcnc.error_channel()

        self.messages = []

        self.persistant = persistent
        self.persistent_file = normalizePath(path=persistent_file,
                                             base=os.getenv(
                                                 'CONFIG_DIR', '~/'))

        self.timer = QTimer()
        self.timer.timeout.connect(self.onTimeout)

        self._count = 0
示例#25
0
    def __init__(self, halcomp,widgets,paths):
        self.hal = halcomp
        self.w = widgets
        self.stat = linuxcnc.stat()
        self.cmnd = linuxcnc.command()
        self.error = linuxcnc.error_channel()
        self.jog_velocity = 10.0
        self.PATH = paths.CONFIGPATH
        self.IMAGE_PATH = paths.IMAGEDIR
        #print paths.CONFIGPATH
        # connect to GStat to catch linuxcnc events
        STATUS.connect('state-estop', self.say_estop)
        STATUS.connect('state-on', self.on_state_on)
        STATUS.connect('state-off', self.on_state_off)
        STATUS.connect('jograte-changed', self.on_jograte_changed)
        STATUS.connect('periodic', self.on_periodic)

        # Read user preferences
        self.desktop_notify = PREFS.getpref('desktop_notify', True, bool)
        self.shutdown_check = PREFS.getpref('shutdown_check', True, bool)
示例#26
0
    def __init__(self, halcomp, widgets, paths):
        self.hal = halcomp
        self.w = widgets
        self.stat = linuxcnc.stat()
        self.cmnd = linuxcnc.command()
        self.error = linuxcnc.error_channel()
        self.jog_velocity = 10.0
        self.PATH = paths.CONFIGPATH
        self.IMAGE_PATH = paths.IMAGEDIR
        #print paths.CONFIGPATH
        # connect to GStat to catch linuxcnc events
        STATUS.connect('state-estop', self.say_estop)
        STATUS.connect('state-on', self.on_state_on)
        STATUS.connect('state-off', self.on_state_off)
        STATUS.connect('jograte-changed', self.on_jograte_changed)
        STATUS.connect('periodic', self.on_periodic)

        # Read user preferences
        self.desktop_notify = PREFS.getpref('desktop_notify', True, bool)
        self.shutdown_check = PREFS.getpref('shutdown_check', True, bool)
示例#27
0
    def init_linuxcnc(self):
        self.stat = linuxcnc.stat()
        self.command = linuxcnc.command()
        self.error_channel = linuxcnc.error_channel()

        try:
            self.stat.poll()
        except linuxcnc.error as e:
            self.error('Unable to poll linuxcnc, is it running?')
            self.error('Error message: {}'.format(e))
            return

        self.serial = self.stat.echo_serial_number
        self.cmd_serial = self.serial + 1
        self.error_channel.poll()

        self.last_interp_state = self.stat.interp_state

        self.poll_task = task.LoopingCall(self.poll_linuxcnc)
        self.poll_task.start(0.1)
        self.state = 'READY'
示例#28
0
    def __init__(self,
                 persistent=True,
                 persistent_file='.qtpyvcp_messages.json'):
        super(Notifications, self).__init__()

        self.error_channel = linuxcnc.error_channel()

        self.messages = []

        self.desktop_notifier = Notification("Demo")
        self.desktop_notifier.setUrgency(Urgency.NORMAL)
        self.desktop_notifier.setCategory("device")

        self.persistant = persistent
        self.persistent_file = normalizePath(path=persistent_file,
                                             base=os.getenv(
                                                 'CONFIG_DIR', '~/'))

        self.timer = QTimer()
        self.timer.timeout.connect(self.onTimeout)

        self._count = 0
示例#29
0
    def __init__(self, stat=None):
        GObject.GObject.__init__(self)

        self.signals = GObject.signal_list_names(self)

        self.stat = stat or linuxcnc.stat()
        self.error = linuxcnc.error_channel()

        self.report_actual_position = ini_info.get_position_feedback()
        axes = ini_info.get_axis_list()
        self.axis_list = ['xyzabcuvw'.index(axis) for axis in axes]
        self.num_joints = ini_info.get_num_joints()

        self.file = None

        self.registry = []
        self.old = {}

        self.old['joint'] = getattr(self.stat, 'joint')

        # Setup joint dict signals
        self.joint_keys = self.old['joint'][0].keys(
        )  # keys() is slow, but we only use it on init
        for key in self.joint_keys:
            key = 'joint-{}'.format(key)
            GObject.signal_new(key.replace('_', '-'), self,
                               GObject.SignalFlags.RUN_FIRST, None,
                               (int, object))

        self.max_time = 0
        self.counter = 0

        # Connect internally used signal callbacks
        self.on_changed('stat.gcodes', self._update_active_gcodes)
        self.on_changed('stat.mcodes', self._update_active_mcodes)
        self.on_changed('stat.file', self._update_file)

        GLib.timeout_add(50, self._periodic)
示例#30
0
 def CALL_MDI_WAIT(self, code, time=5, mode_return=False):
     LOG.debug('MDI_WAIT_Command= {}, maxt = {}'.format(code, time))
     fail, premode = self.ensure_mode(linuxcnc.MODE_MDI)
     for l in code.split("\n"):
         LOG.debug('CALL_MDI_WAIT Command: {}'.format(l))
         self.cmd.mdi(l)
         result = self.cmd.wait_complete(time)
         if result == -1:
             LOG.error('CALL_MDI_WAIT timeout surpassed {} seconds'.format(time))
             # STATUS.emit('MDI time out error',)
             self.ABORT()
             return -1
         elif result == linuxcnc.RCS_ERROR:
             LOG.debug('CALL_MDI_WAIT RCS error: {}'.format(time, result))
             return -1
         result = linuxcnc.error_channel().poll()
         if result:
             STATUS.emit('error', result[0], result[1])
             LOG.error('CALL_MDI_WAIT Error: {}'.format(result[1]))
             return -1
     if mode_return:
         self.ensure_mode(premode)
     return 0
示例#31
0
    def __init__(self, halcomp,builder,useropts):
        self.halcomp = halcomp
        self.builder = builder

        (directory,filename) = os.path.split(__file__)
        (basename,extension) = os.path.splitext(filename)
        self.ini_filename = os.path.join(directory,basename + '.ini')
        self.defaults = {  IniFile.vars: { },
                           IniFile.widgets: widget_defaults(select_widgets(self.builder.get_objects(),
                                                                           hal_only=True,output_only = True)),
                                                                           }
        self.ini = IniFile(self.ini_filename,self.defaults, self.builder)
        self.ini.restore_state(self)

        self.c = linuxcnc.command()
        self.e = linuxcnc.error_channel()
        self.s = linuxcnc.stat()

        self.state = hal_glib.GPin(halcomp.newpin('state', hal.HAL_S32, hal.HAL_IN))
        self.state.connect('value-changed', self._on_state_changed)

        self.motion_type  = hal_glib.GPin(halcomp.newpin('motion_type', hal.HAL_S32, hal.HAL_IN))
        self.motion_type.connect('value-changed', self._on_motion_type_changed)
示例#32
0
文件: cutmat.py 项目: cnc-club/bbox
	def __init__(self):

		self.builder = gtk.Builder()
		self.builder.add_from_file(glade_file)
		self.builder.connect_signals(self)
		self.connect_signals()
		self.halcomp = hal.component("cutmat")
		panel = gladevcp.makepins.GladePanel( self.halcomp, glade_file, self.builder, None)		
		self.window = self.builder.get_object("window1")
		self.linuxcnc_ini = linuxcnc.ini(LINUXCNC_INI)
		self.window.show()
		self.window.connect("key-press-event", self.on_key_down)		
		self.window.connect("delete-event", self.on_window_destroy)		
		# init cfg
		self.c = linuxcnc.command()
		self.err = linuxcnc.error_channel()	
		# post gui
		print "Cutmat: loading postgui hal file"
		postgui_halfile = self.linuxcnc_ini.find("HAL", "POSTGUI_HALFILE")	
		print 	postgui_halfile
		p = subprocess.Popen(['halcmd', '-i', LINUXCNC_INI, "-f", postgui_halfile], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
		out, err = p.communicate()
		print out, err
    def __init__(self, halcomp, builder, useropts, gscreen):

        self.command = linuxcnc.command()
        self.error_channel = linuxcnc.error_channel()

        self.stat = linuxcnc.stat()
        self.gscreen = gscreen
        self.emc = gscreen.emc
        self.data = gscreen.data
        self.widgets = gscreen.widgets

        #self.data.current_jogincr_index = 7

        self.xpos = 0
        self.ypos = 0
        self.width = 0
        self.height = 0
        self.initialized = False

        self.data.sensitive_on_off = ["b", "f_mode", "f_other"]
        self.data.sensitive_AUTO_off = [
            "f_axis", "f_spindle", "f_coolant", "f_overrides", "f_f", "f_probe"
        ]
        self.data.sensitive_MAN_off = ["f_basic"]
示例#34
0
    def __init__(self, parent=None):
        super(ScreenOptions, self).__init__(parent)
        self.error = linuxcnc.error_channel()
        self.catch_errors = True
        self.desktop_notify = True
        self.close_event = True
        self.play_sounds = True
        self.mchnMsg_play_sound = True
        self.usrMsg_play_sound = True
        self.usrMsg_sound_type = 'READY'
        self.usrMsg_use_FocusOverlay = True
        self.play_shutdown_sounds = True
        self.user_messages = True
        self.use_pref_file = True
        self.add_entry_dialog = False
        self.add_tool_dialog = False
        self.add_file_dialog = False
        self.add_focus_overlay = False
        self.add_versaprobe_dialog = False
        self.add_macrotab_dialog = False
        self.add_camview_dialog = False
        self.add_originoffset_dialog = False
        self.add_tooloffset_dialog = False
        self.add_calculator_dialog = False

        self.pref_filename = '~/.qtvcp_screen_preferences'
        self._close_color = QtGui.QColor(100, 0, 0, 150)
        self._entryDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._toolDialogColor = QtGui.QColor(100, 0, 0, 150)
        self._fileDialogColor = QtGui.QColor(0, 0, 100, 150)
        self._versaProbeDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._macroTabDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._camViewDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._originOffsetDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._toolOffsetDialogColor = QtGui.QColor(0, 0, 0, 150)
        self._calculatorDialogColor = QtGui.QColor(0, 0, 0, 150)
示例#35
0
import time
import sys
import os

# Time increment and timeout, seconds
TIME_INCR = 0.1
TIMEOUT = 10.0

#
# connect to LinuxCNC
#

c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)


#
# Create and connect test feedback comp
#
h = hal.component("test-ui")
h.newpin("Xpos", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("Ypos", hal.HAL_FLOAT, hal.HAL_IN)
h.ready()
os.system("halcmd source ./postgui.hal")

#
# Come out of E-stop, turn the machine on, home
#
示例#36
0
 def __init__(self):
     self.c = linuxcnc.command()
     self.e = linuxcnc.error_channel()
     self.s = linuxcnc.stat()
示例#37
0
#
# set up pins
# shell out to halcmd to net our pins to where they need to go
#

h = hal.component("python-ui")
h.ready()


#
# connect to LinuxCNC
#

c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()

l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)

c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(0)
c.home(1)
c.home(2)
l.wait_for_home([1, 1, 1, 0, 0, 0, 0, 0, 0])

c.mode(linuxcnc.MODE_AUTO)

c.program_open("test.ngc")
c.auto(linuxcnc.AUTO_RUN, 1)
示例#38
0
        return 0


class fake_command():
    def __getattr__(self, name):
        return lambda *args: None


try:
    import linuxcnc as LINUXCNC
    import gcode as GCODE
    import hal as HAL

    STAT = LINUXCNC.stat()
    COMMAND = LINUXCNC.command()
    ERROR = LINUXCNC.error_channel()
    POSLOG = LINUXCNC.positionlogger
    INI = LINUXCNC.ini(os.environ['INI_FILE_NAME'])

    STAT.poll()
    ERROR.poll()

    from alterx.core.remote import RemoteControl

    port = INI.find("DISPLAY", "REMOTE_PORT") or RemoteControl.PORT
    if port:
        RemoteControl.PORT = port
        REMOTE = RemoteControl()

except Exception as e:
    printError(_("Failed to import LinuxCNC module: '{}'", e))
 def __init__(self):
     self.cmd = mk.command()
     self.err = mk.error_channel()
     self.stat = mk.stat()
示例#40
0
class PageMaker(uweb.DebuggingPageMaker):
    """Holds all the html generators for the webapp.

  Each page as a separate method
  """

    # XXX: this is put in varible rather than a property becouse linuxcnc doesn't
    # XXX: seem to play nice with them and will require you to run a c.[command]
    # XXX: twice making for wierd code and the gain from putting them in a property
    # XXX: is neglectable
    s = linuxcnc.stat()
    c = linuxcnc.command()
    e = linuxcnc.error_channel()

    @property
    def axis(self):
        if hasattr(self, '_axis'):
            return self._axis
        self._axis = {
            0: "X",
            1: "Y",
            2: "Z",
            3: "A",
            4: "B",
            5: "C",
            6: "U",
            7: "V",
            8: "W",
            9: "R"
        }
        return self._axis

    @property
    def axisInMachine(self):
        if hasattr(self, '_axisInMachine'):
            return self._axisInMachine

        self.s.poll()
        pos = self.s.actual_position
        allAxis = []
        axis = self.s.axis
        count = 0
        axisthing = []
        for i in pos:
            if axis[count]["max_position_limit"] != 0.0:
                allAxis.append(count)
            else:
                axisthing.append(axis[count]["max_position_limit"])
            count += 1
        self._axisInMachine = allAxis
        return self._axisInMachine

    @property
    def headz(self):
        if hasattr(self, '_headz'):
            return self._headz
        return None

    @headz.setter
    def headz(self, value):
        self._headz = value

    @decorators.head
    def Test(self):
        pass

    # methods bound to a link
    def Index(self):
        """Return the index.html template."""
        return self.parser.Parse('index.html')

    def Position(self):
        """Return and set the position of all axis in machine."""

        # if you wanna change how the POST works, do it here
        def post():
            """will allow you to set the position of the head"""
            self.s.poll()
            gcode = "G1 "
            pos = self.s.actual_position
            temp = []
            for i in self.axisInMachine:
                if self.post.getfirst(self.axis[i]):
                    gcode = gcode + "%s%s " % (
                        self.axis[i], self.post.getfirst(self.axis[i]))

            if self.post.getfirst("F"):
                gcode = gcode + "F%s" % self.post.getfirst("F")
            else:
                gcode + "F10000"
            self.c.mdi(gcode)

        # if you wanna change how the GET works, do it here
        @decorators.JsonResponse
        def get():
            """Will give you the current position of the head."""
            self.s.poll()
            pos = self.s.actual_position
            temp = []
            axis = axis_max = axis_min = {}
            for i in self.axisInMachine:
                axis.update({"%s" % self.axis[i]: pos[i]})
                axis_max.update({
                    "%s" % self.axis[i]:
                    self.s.axis[i]["max_position_limit"]
                })
                axis_min.update({
                    "%s" % self.axis[i]:
                    self.s.axis[i]["min_position_limit"]
                })
            Rjson = {"axis": axis, "axis_max": axis_max, "axis_min": axis_min}
            return Rjson

        req = self.req.env["REQUEST_METHOD"]

        if req == "GET":
            return get()
        elif req == "POST":
            post()

    @decorators.haspost(['File'])
    def File(self):
        """GET will return file running.

    POST will allow you to run a file.
    """
        @decorators.JsonResponse
        def get():
            """Will return if a file is running and if yes which."""
            self.s.poll()
            file = self.s.file
            if file != "":
                Temp = file.split("/")
                running = [True, Temp[len(Temp) - 1]]
            else:
                running = [False, "no file running"]
            Rjson = {
                "Running": running[0],
                "Running_file": running[1],
                "file": file
            }
            return Rjson

        def post():
            """Will allow you to set the file it should run."""
            try:
                fileData = self.post["File"].value
                fileName = self.post["File"].filename
                self.s.poll()
                self.c.mode(linuxcnc.MODE_AUTO)
                self.c.wait_complete()
                with open("armApi/temp.ngc", "w") as File:
                    File.write(fileData)
                self.c.program_open("armApi/temp.ngc")
                self.c.wait_complete()
                self.c.auto(linuxcnc.AUTO_RUN, 1)
                Rjson = {"fileData": fileData, "fileName": fileName}
            except Exception:
                pass

        req = self.req.env["REQUEST_METHOD"]

        if req == "GET":
            return get()
        elif req == "POST":
            post()

    @decorators.head
    def Stats(self):
        """GET link will return the stats of the machine.

    HEAD will allow you to set some stats.
    """
        @decorators.JsonResponse
        def get():
            """Will return you some stats of the machine."""
            self.s.poll()
            Max_vel = self.s.max_velocity
            Spin_rate = self.s.spindle_speed
            Axis = []
            for i in self.axisInMachine:
                Axis.append(self.axis[i])
            sum = self.s.axis[0]["velocity"] + self.s.axis[1][
                "velocity"] + self.s.axis[2]["velocity"]
            Current_speed = sum / 3
            Feed_rate = self.s.feedrate
            Rjson = {
                "Max_vel": Max_vel,
                "Spin_rate": Spin_rate,
                "Axis": Axis,
                "Current_speed": Current_speed,
                "Feed_rate": Feed_rate,
            }
            return Rjson

        def head():
            """Will allow you to change some of the stats of the machine."""
            if self.headz['Max_vel']:
                self.c.maxvel(float(self.headz["Max_vel"]))
            if self.headz['Spin_rate']:
                # TODO: there doesn't seem to be a call that can change the spin rate
                # TODO: but if found put here
                pass
            if self.headz['Feed_rate']:
                self.c.feedrate(float(self.headz["Feed_rate"]))

        req = self.req.env["REQUEST_METHOD"]

        if req == "GET":
            return get()
        elif req == "HEAD":
            head()

    def Home(self):
        """GET will return homed flag.

    POST will home the machine.
    """
        def get():
            """Will return which of the axis are homed and which are not."""
            self.s.poll()
            home = self.s.homed
            if 0 in home:
                home = False
            else:
                home = True
            return home

        def post():
            """Will allow you to tell the machine to go home."""  # It doesn't even have to be drunk.
            if self.req.env["REQUEST_METHOD"] == "POST":
                for i in self.axisInMachine:
                    self.c.home(i)
                    self.c.wait_complete()

        req = self.req.env["REQUEST_METHOD"]

        if req == "GET":
            return get()
        elif req == "POST":
            post()

    @decorators.haspost(['Command'])
    def Buttons(self):
        """Buttons can handle button commands."""
        if self.req.env["REQUEST_METHOD"] == "POST":
            if self.post.getfirst("Command") == "Mdi_mode":
                self.c.mode(linuxcnc.MODE_MDI)
            elif self.post.getfirst("Command") == "Estop":
                self.s.poll()
                if self.s.estop:
                    self.c.state(2)
                else:
                    self.c.state(1)
            elif self.post.getfirst("Command") == "Stop":
                self.c.abort()
            elif self.post.getfirst("Command") == "Pause":
                self.c.auto(linuxcnc.AUTO_PAUSE)
            elif self.post.getfirst("Command") == "Resume":
                self.c.auto(linuxcnc.AUTO_RESUME)
            elif self.post.getfirst("Command") == "Repeat":
                self.c.mode(linuxcnc.MODE_AUTO)
                self.c.program_open("armApi/temp.ngc")
                self.c.wait_complete()
                self.c.auto(linuxcnc.AUTO_RUN, 1)

    @decorators.head
    def Prefabs(self):
        """GET will return all prefabs saved in the prefabs folder.

    POST will allow you to save a file in the machine.

    HEAD will allow you to run the file given.
    """
        # this is will make sure that all ids in the file are one of a kind
        File = open("armApi/prefabs/0&amount.txt", "w")
        File.close()
        File = open("armApi/prefabs/0&amount.txt", "r+")
        if File.read() == "":
            File.write("%s" % len(os.listdir("armApi/prefabs")))
            File.close()
        else:
            files = os.listdir("armApi/prefabs/")
            number = int(files[0].split("&")[0]) + 1
            File = open("armApi/prefabs/0&amount.txt", "w")
            File.write("%s" % number)

        @decorators.JsonResponse
        def get():
            """Will allow you to get all the files stored and there content."""
            Rjson = {}
            for i in os.listdir("armApi/prefabs"):
                compon = i.split("&")
                File = open("armApi/prefabs/%s" % i, "r")
                Rjson.update({
                    "%s" % compon[0]: {
                        "name": compon[1],
                        "content": File.read()
                    }
                })
            return Rjson

        def post():
            """Will allow you to send a file and store it in the server."""
            name = self.post["file"].filename
            content = self.post["file"].value
            File = open("armApi/prefabs/0&amount.txt", "r")
            number = File.read()
            File = open("armApi/prefabs/%s&%s" % (number, name), "w")
            try:
                File.write(unicode(content, "utf-8"))
            except Exception:
                pass

        def head():
            """Will allow you to run a file on the server."""
            if self.req.env["REQUEST_METHOD"] == "HEAD":
                id = self.headz["id"]
                for i in os.listdir("armApi/prefabs"):
                    name = i.split("&")[0]
                    if name == id:
                        fullname = i
                self.c.mode(linuxcnc.MODE_AUTO)
                self.c.wait_complete()
                self.c.program_open("/armApi/prefabs/%s" % fullname)
                self.c.wait_complete()
                self.c.auto(linuxcnc.AUTO_RUN, 1)

        if self.req.env["REQUEST_METHOD"] == "GET":
            return get()
        elif self.req.env["REQUEST_METHOD"] == "POST":
            post()
        elif self.req.env["REQUEST_METHOD"] == "HEAD":
            head()

    def Power(self):
        """GET will return the power flag.

    POST will allow you to turn the power on and off.
    """
        def get():
            """Will return the power status."""
            self.s.poll()
            return self.s.axis[1]["enabled"]

        def post():
            """Will allow you to toggel the power."""
            self.s.poll()
            on = self.s.axis[1]["enabled"]
            if on:
                self.c.state(3)
            else:
                self.c.state(4)
            self.Index()

        req = self.req.env["REQUEST_METHOD"]

        if req == "GET":
            return get()
        elif req == "POST":
            post()

    @decorators.JsonResponse
    def Status(self):
        """GET will return return the status of some stuff look in the doc for specifics."""
        if self.req.env["REQUEST_METHOD"] == "GET":
            Rjson = {}
            self.s.poll()
            home = self.s.homed
            if 0 in home:
                home = False
            file = self.s.file
            if file != "":
                running = True
            Rjson.update({"Power": self.s.axis[1]["enabled"]})
            Rjson.update({"Home": home})
            Rjson.update({"Active": running})
            return Rjson

    def Coolant(self):
        """GET will return the mist and flood flags.

    POST will allow you to turn the mist and flood on and off.
    """
        self.s.poll()

        @decorators.JsonResponse
        def get():
            """Will return the mist, flood status."""
            return {"mist": self.s.mist, "flood": self.s.flood}

        @decorators.haspost(["FOM"])
        def post(self):
            """Will allow you to toggel the mist and flood."""
            self.s.poll()
            if self.post.getfirst("FOM") == "flood":
                if self.s.flood == 1:
                    self.c.flood(linuxcnc.FLOOD_OFF)
                else:
                    self.c.flood(linuxcnc.FLOOD_ON)
            if self.post.getfirst("FOM") == "mist":
                if self.s.mist == 1:
                    self.c.mist(linuxcnc.MIST_OFF)
                else:
                    self.c.mist(linuxcnc.MIST_ON)
            self.s.poll()

        req = self.req.env["REQUEST_METHOD"]

        if req == "GET":
            return get()
        elif req == "POST":
            # XXX: the self is for the decorator
            post(self)

    @decorators.JsonResponse
    def Error(self):
        """Return errors form the machine."""
        error = self.e.poll()

        if error:
            kind, msg = error
            if kind in (linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR):
                typus = "error"
            else:
                typus = "info"
            return {"type": typus, "msg": msg}

    def FourOhFour(self, path):
        """The request could not be fulfilled, this returns a 404."""
        return uweb.Response(self.parser.Parse('404.utp', path=path),
                             httpcode=404)
示例#41
0
 def __init__(self, timeout=2):
     self.c = linuxcnc.command()
     self.e = linuxcnc.error_channel()
     self.s = linuxcnc.stat()
     self.timeout = timeout
示例#42
0
 def __init__(self,timeout=2):
     self.c = linuxcnc.command()
     self.e = linuxcnc.error_channel()
     self.s = linuxcnc.stat()
     self.timeout = timeout
示例#43
0
 def __init__(self):
     self.c = linuxcnc.command()
     self.e = linuxcnc.error_channel()
     self.s = linuxcnc.stat()