def periodic(self):
                self.emcstat.poll()
                am = self.emcstat.axis_mask
                lathe = not (self.emcstat.axis_mask & 2)
                dtg = self.emcstat.dtg

                if not self.resized_dro:
                        height = 9
                        for i in range(9):
                                if i == 1 and lathe:
                                        continue
                                if not (am & (1<<i)):
                                        height -= 1
                                        self.dro_table.remove(self.relative[height])
                                        self.dro_table.remove(self.absolute[height])
                                        self.dro_table.remove(self.distance[height])
                                        
                        self.dro_table.resize(height, 3)
                        self.resized_dro = 1
                                        
                if self.actual:
                        p = self.emcstat.actual_position
                else:
                        p = self.emcstat.position

                x = p[0] - self.emcstat.g5x_offset[0] - self.emcstat.tool_offset[0]
                y = p[1] - self.emcstat.g5x_offset[1] - self.emcstat.tool_offset[1]
                z = p[2] - self.emcstat.g5x_offset[2] - self.emcstat.tool_offset[2]
                a = p[3] - self.emcstat.g5x_offset[3] - self.emcstat.tool_offset[3]
                b = p[4] - self.emcstat.g5x_offset[4] - self.emcstat.tool_offset[4]
                c = p[5] - self.emcstat.g5x_offset[5] - self.emcstat.tool_offset[5]
                u = p[6] - self.emcstat.g5x_offset[6] - self.emcstat.tool_offset[6]
                v = p[7] - self.emcstat.g5x_offset[7] - self.emcstat.tool_offset[7]
                w = p[8] - self.emcstat.g5x_offset[8] - self.emcstat.tool_offset[8]

                if self.emcstat.rotation_xy != 0:
                        t = math.radians(-self.emcstat.rotation_xy)
                        xr = x * math.cos(t) - y * math.sin(t)
                        yr = x * math.sin(t) + y * math.cos(t)
                        x = xr
                        y = yr

                x -= self.emcstat.g92_offset[0] 
                y -= self.emcstat.g92_offset[1] 
                z -= self.emcstat.g92_offset[2] 
                a -= self.emcstat.g92_offset[3] 
                b -= self.emcstat.g92_offset[4] 
                c -= self.emcstat.g92_offset[5] 
                u -= self.emcstat.g92_offset[6] 
                v -= self.emcstat.g92_offset[7] 
                w -= self.emcstat.g92_offset[8] 

                relp = [x, y, z, a, b, c, u, v, w]

                if self.mm != self.machine_units_mm:
                        p = self.convert_units(p,self.unit_convert)
                        relp = self.convert_units(relp,self.unit_convert)
                        dtg = self.convert_units(dtg,self.unit_convert)

                if self.mm:
                        fmt = "%c:% 10.3f"
                else:
                        fmt = "%c:% 9.4f"

                d = 0
                if (am & 1):
                        h = " "
                        if self.emcstat.homed[0]: h = "*"
                        
                        if lathe:
                                set_text(self.relative[d], fmt % ('R', relp[0]))
                                set_text(self.absolute[d], h + fmt % ('R', p[0]))
                                set_text(self.distance[d], fmt % ('R', dtg[0]))
                                d += 1
                                set_text(self.relative[d], fmt % ('D', relp[0] * 2.0))
                                set_text(self.absolute[d], " " + fmt % ('D', p[0] * 2.0))
                                set_text(self.distance[d], fmt % ('D', dtg[0] * 2.0))
                        else:
                                set_text(self.relative[d], fmt % ('X', relp[0]))
                                set_text(self.absolute[d], h + fmt % ('X', p[0]))
                                set_text(self.distance[d], fmt % ('X', dtg[0]))

                        d += 1
                        
                for i in range(1, 9):
                        h = " "
                        if self.emcstat.homed[i]: h = "*"
                        if am & (1<<i):
                                letter = 'XYZABCUVW'[i]
                                set_text(self.relative[d], fmt % (letter, relp[i]))
                                set_text(self.absolute[d], h + fmt % (letter, p[i]))
                                set_text(self.distance[d], fmt % (letter, dtg[i]))
                                d += 1

                estopped = self.emcstat.task_state == self.emc.STATE_ESTOP
                set_active(self.estops['estop'], estopped)
                set_active(self.estops['estop_reset'], not estopped)

                on = self.emcstat.task_state == self.emc.STATE_ON
                set_active(self.machines['on'], on)
                set_active(self.machines['off'], not on)

                ovl = self.emcstat.axis[0]['override_limits']
                set_active(self.override_limit, ovl)

                set_text(self.status['file'], self.emcstat.file)
                set_text(self.status['file_lines'], "%d" % len(self.listing.program))
                set_text(self.status['line'], "%d" % self.emcstat.current_line)
                set_text(self.status['id'], "%d" % self.emcstat.id)
                set_text(self.status['dtg'], "%.4f" % self.emcstat.distance_to_go)
                set_text(self.status['velocity'], "%.4f" % (self.emcstat.current_vel * 60.0))
                set_text(self.status['delay'], "%.2f" % self.emcstat.delay_left)

                flood = self.emcstat.flood
                set_active(self.floods['on'], flood)
                set_active(self.floods['off'], not flood)

                mist = self.emcstat.mist
                set_active(self.mists['on'], mist)
                set_active(self.mists['off'], not mist)

                spin = self.emcstat.spindle_direction
                set_active(self.spindles['forward'], spin == 1)
                set_active(self.spindles['off'], spin == 0)
                set_active(self.spindles['reverse'], spin == -1)

                ol = ""
                for i in range(len(self.emcstat.limit)):
                        if self.emcstat.limit[i]:
                                ol += "%c " % "XYZABCUVW"[i]
                set_text(self.status['onlimit'], ol)

                sd = (_("CCW"), _("Stopped"), _("CW"))
                set_text(self.status['spindledir'], sd[self.emcstat.spindle_direction+1])

                set_text(self.status['spindlespeed'], "%d" % self.emcstat.spindle_speed)
                set_text(self.status['spindlespeed2'], "%d" % self.emcstat.spindle_speed)
                set_text(self.status['loadedtool'], "%d" % self.emcstat.tool_in_spindle)
		if self.emcstat.pocket_prepped == -1:
			set_text(self.status['preppedtool'], _("None"))
		else:
			set_text(self.status['preppedtool'], "%d" % self.emcstat.tool_table[self.emcstat.pocket_prepped].id)

                tt = ""
                for p, t in zip(range(len(self.emcstat.tool_table)), self.emcstat.tool_table):
                        if t.id != -1:
                                tt += "<b>P%02d:</b>T%02d\t" % (p, t.id)
                                if p == 0: tt += '\n'
                set_text(self.status['tooltable'], tt)
                        
                
                set_text(self.status['xyrotation'], "%d" % self.emcstat.rotation_xy)
                set_text(self.status['tlo'], "%.4f" % self.emcstat.tool_offset[2])

                cs = self.emcstat.g5x_index
                if cs<7:
                        cslabel = "G5%d" % (cs+3)
                else:
                        cslabel = "G59.%d" % (cs-6)
                        
                set_text(self.status['label_g5xoffset'], '<b>' + cslabel + '</b>' + ' Offset:');

                g5x = ""
                g92 = ""
                for i in range(len(self.emcstat.g5x_offset)):
                        letter = "XYZABCUVW"[i]
                        if self.emcstat.g5x_offset[i] != 0: g5x += "%s%.4f " % (letter, self.emcstat.g5x_offset[i])
                        if self.emcstat.g92_offset[i] != 0: g92 += "%s%.4f " % (letter, self.emcstat.g92_offset[i])
                                   
                set_text(self.status['g5xoffset'], g5x);
                set_text(self.status['g92offset'], g92);

                active_codes = []
                for i in self.emcstat.gcodes[1:]:
                        if i == -1: continue
                        if i % 10 == 0:
                                active_codes.append("G%d" % (i/10))
                        else:
                                active_codes.append("G%d.%d" % (i/10, i%10))

                for i in self.emcstat.mcodes[1:]:
                        if i == -1: continue
                        active_codes.append("M%d" % i)

                feed_str = "F%.1f" % self.emcstat.settings[1]
                if feed_str.endswith(".0"): feed_str = feed_str[:-2]
                active_codes.append(feed_str)
                active_codes.append("S%.0f" % self.emcstat.settings[2])

                set_text(self.status['activecodes'], " ".join(active_codes))

                set_active(self.prefs['inch'], self.mm == 0)
                set_active(self.prefs['mm'], self.mm == 1)
                set_active(self.prefs['actual'], self.actual == 1)
                set_active(self.prefs['commanded'], self.actual == 0)

                set_active(self.opstop['on'], self.emcstat.optional_stop)
                set_active(self.opstop['off'], not self.emcstat.optional_stop)
                
                set_active(self.blockdel['on'], self.emcstat.block_delete)
                set_active(self.blockdel['off'], not self.emcstat.block_delete)
                

                if self.emcstat.id == 0 and (self.emcstat.interp_state == self.emc.INTERP_PAUSED or self.emcstat.exec_state == self.emc.EXEC_WAITING_FOR_DELAY):
                        self.listing.highlight_line(self.emcstat.current_line)
                elif self.emcstat.id == 0:
                        self.listing.highlight_line(self.emcstat.motion_line)
                else:
                        self.listing.highlight_line(self.emcstat.id or self.emcstat.motion_line)

                e = self.emcerror.poll()
                if e:
                        kind, text = e
                        set_text(self.error, text)
Example #2
0
        def periodic(self):
                self.emcstat.poll()
                am = self.emcstat.axis_mask
                lathe = not (self.emcstat.axis_mask & 2)
                dtg = self.emcstat.dtg

                if not self.resized_dro:
                        height = 9
                        for i in range(9):
                                if i == 1 and lathe:
                                        continue
                                if not (am & (1<<i)):
                                        height -= 1
                                        self.dro_table.remove(self.relative[height])
                                        self.dro_table.remove(self.absolute[height])
                                        self.dro_table.remove(self.distance[height])
                                        
                        self.dro_table.resize(height, 3)
                        self.resized_dro = 1
                                        
                if self.actual:
                        p = self.emcstat.actual_position
                else:
                        p = self.emcstat.position

                x = p[0] - self.emcstat.origin[0] - self.emcstat.tool_offset[0]
                y = p[1] - self.emcstat.origin[1]
                z = p[2] - self.emcstat.origin[2] - self.emcstat.tool_offset[2]
                a = p[3] - self.emcstat.origin[3]
                b = p[4] - self.emcstat.origin[4]
                c = p[5] - self.emcstat.origin[5]
                u = p[6] - self.emcstat.origin[6]
                v = p[7] - self.emcstat.origin[7]
                w = p[8] - self.emcstat.origin[8] - self.emcstat.tool_offset[8]
                t = math.radians(-self.emcstat.rotation_xy)
                relp = [x * math.cos(t) - y * math.sin(t), x * math.sin(t) + y * math.cos(t), z, a, b, c, u, v, w]

                if self.mm:
                        p = [i*25.4 for i in p]
                        relp = [i*25.4 for i in relp]
                        dtg = [i*25.4 for i in dtg]
                        fmt = "%c:% 10.3f"
                else:
                        fmt = "%c:% 9.4f"

                d = 0
                if (am & 1):
                        h = " "
                        if self.emcstat.homed[0]: h = "*"
                        
                        if lathe:
                                set_text(self.relative[d], fmt % ('R', relp[0]))
                                set_text(self.absolute[d], h + fmt % ('R', p[0]))
                                set_text(self.distance[d], fmt % ('R', dtg[0]))
                                d += 1
                                set_text(self.relative[d], fmt % ('D', relp[0] * 2.0))
                                set_text(self.absolute[d], fmt % ('D', p[0] * 2.0))
                                set_text(self.distance[d], fmt % ('D', dtg[0] * 2.0))
                        else:
                                set_text(self.relative[d], fmt % ('X', relp[0]))
                                set_text(self.absolute[d], h + fmt % ('X', p[0]))
                                set_text(self.distance[d], fmt % ('X', dtg[0]))

                        d += 1
                        
                for i in range(1, 9):
                        h = " "
                        if self.emcstat.homed[i]: h = "*"
                        if am & (1<<i):
                                letter = 'XYZABCUVW'[i]
                                set_text(self.relative[d], fmt % (letter, relp[i]))
                                set_text(self.absolute[d], h + fmt % (letter, p[i]))
                                set_text(self.distance[d], fmt % (letter, dtg[i]))
                                d += 1

                estopped = self.emcstat.task_state == self.emc.STATE_ESTOP
                set_active(self.estops['estop'], estopped)
                set_active(self.estops['estop_reset'], not estopped)

                on = self.emcstat.task_state == self.emc.STATE_ON
                set_active(self.machines['on'], on)
                set_active(self.machines['off'], not on)

                ovl = self.emcstat.axis[0]['override_limits']
                set_active(self.override_limit, ovl)

                set_text(self.status['file'], self.emcstat.file)
                set_text(self.status['line'], "%d" % self.emcstat.current_line)
                set_text(self.status['id'], "%d" % self.emcstat.id)
                set_text(self.status['dtg'], "%f" % self.emcstat.distance_to_go)
                set_text(self.status['velocity'], "%f" % (self.emcstat.current_vel * 60.0))
                set_text(self.status['delay'], "%f" % self.emcstat.delay_left)

                flood = self.emcstat.flood
                set_active(self.floods['on'], flood)
                set_active(self.floods['off'], not flood)

                mist = self.emcstat.mist
                set_active(self.mists['on'], mist)
                set_active(self.mists['off'], not mist)

                spin = self.emcstat.spindle_direction
                set_active(self.spindles['forward'], spin == 1)
                set_active(self.spindles['off'], spin == 0)
                set_active(self.spindles['reverse'], spin == -1)

                ol = ""
                for i in range(len(self.emcstat.limit)):
                        if self.emcstat.limit[i]:
                                ol += "%c " % "XYZABCUVW"[i]
                set_text(self.status['onlimit'], ol)

                sd = (_("CCW"), _("Stopped"), _("CW"))
                set_text(self.status['spindledir'], sd[self.emcstat.spindle_direction+1])

                set_text(self.status['spindlespeed'], "%d" % self.emcstat.spindle_speed)
                set_text(self.status['loadedtool'], "%d" % self.emcstat.tool_in_spindle)
		if self.emcstat.pocket_prepped == -1:
			set_text(self.status['preppedtool'], _("None"))
		else:
			set_text(self.status['preppedtool'], "%d" % self.emcstat.tool_table[self.emcstat.pocket_prepped].id)
                set_text(self.status['xyrotation'], "%d" % self.emcstat.rotation_xy)
                set_text(self.status['tlo'], "%f" % self.emcstat.tool_offset[2])

                active_codes = []
                for i in self.emcstat.gcodes[1:]:
                        if i == -1: continue
                        if i % 10 == 0:
                                active_codes.append("G%d" % (i/10))
                        else:
                                active_codes.append("G%d.%d" % (i/10, 1%10))

                for i in self.emcstat.mcodes[1:]:
                        if i == -1: continue
                        active_codes.append("M%d" % i)

                feed_str = "F%.1f" % self.emcstat.settings[1]
                if feed_str.endswith(".0"): feed_str = feed_str[:-2]
                active_codes.append(feed_str)
                active_codes.append("S%.0f" % self.emcstat.settings[2])

                set_text(self.status['activecodes'], " ".join(active_codes))

                set_active(self.prefs['inch'], self.mm == 0)
                set_active(self.prefs['mm'], self.mm == 1)
                set_active(self.prefs['actual'], self.actual == 1)
                set_active(self.prefs['commanded'], self.actual == 0)

                set_active(self.opstop['on'], self.emcstat.optional_stop)
                set_active(self.opstop['off'], not self.emcstat.optional_stop)
                
                set_active(self.blockdel['on'], self.emcstat.block_delete)
                set_active(self.blockdel['off'], not self.emcstat.block_delete)
                

                if self.emcstat.id == 0 and (self.emcstat.interp_state == self.emc.INTERP_PAUSED or self.emcstat.exec_state == self.emc.EXEC_WAITING_FOR_DELAY):
                        self.listing.highlight_line(self.emcstat.current_line)
                elif self.emcstat.id == 0:
                        self.listing.highlight_line(self.emcstat.motion_line)
                else:
                        self.listing.highlight_line(self.emcstat.id or self.emcstat.motion_line)

                e = self.emcerror.poll()
                if e:
                        kind, text = e
                        set_text(self.error, text)
 def abort(self):
         self.emccommand.abort()
         set_text(self.error, "")
Example #4
0
    def periodic(self):
        self.emcstat.poll()
        am = self.emcstat.axis_mask
        lathe = not (self.emcstat.axis_mask & 2)
        dtg = self.emcstat.dtg

        if not self.resized_dro:
            height = 9
            for i in range(9):
                if i == 1 and lathe:
                    continue
                if not (am & (1 << i)):
                    height -= 1
                    self.dro_table.remove(self.relative[height])
                    self.dro_table.remove(self.absolute[height])
                    self.dro_table.remove(self.distance[height])

            self.dro_table.resize(height, 3)
            self.resized_dro = 1

        if self.actual:
            p = self.emcstat.actual_position
        else:
            p = self.emcstat.position

        x = p[0] - self.emcstat.origin[0] - self.emcstat.tool_offset[0]
        y = p[1] - self.emcstat.origin[1]
        z = p[2] - self.emcstat.origin[2] - self.emcstat.tool_offset[2]
        a = p[3] - self.emcstat.origin[3]
        b = p[4] - self.emcstat.origin[4]
        c = p[5] - self.emcstat.origin[5]
        u = p[6] - self.emcstat.origin[6]
        v = p[7] - self.emcstat.origin[7]
        w = p[8] - self.emcstat.origin[8] - self.emcstat.tool_offset[8]
        t = math.radians(-self.emcstat.rotation_xy)
        relp = [
            x * math.cos(t) - y * math.sin(t),
            x * math.sin(t) + y * math.cos(t), z, a, b, c, u, v, w
        ]

        if self.mm:
            p = [i * 25.4 for i in p]
            relp = [i * 25.4 for i in relp]
            dtg = [i * 25.4 for i in dtg]
            fmt = "%c:% 10.3f"
        else:
            fmt = "%c:% 9.4f"

        d = 0
        if (am & 1):
            h = " "
            if self.emcstat.homed[0]: h = "*"

            if lathe:
                set_text(self.relative[d], fmt % ('R', relp[0]))
                set_text(self.absolute[d], h + fmt % ('R', p[0]))
                set_text(self.distance[d], fmt % ('R', dtg[0]))
                d += 1
                set_text(self.relative[d], fmt % ('D', relp[0] * 2.0))
                set_text(self.absolute[d], fmt % ('D', p[0] * 2.0))
                set_text(self.distance[d], fmt % ('D', dtg[0] * 2.0))
            else:
                set_text(self.relative[d], fmt % ('X', relp[0]))
                set_text(self.absolute[d], h + fmt % ('X', p[0]))
                set_text(self.distance[d], fmt % ('X', dtg[0]))

            d += 1

        for i in range(1, 9):
            h = " "
            if self.emcstat.homed[i]: h = "*"
            if am & (1 << i):
                letter = 'XYZABCUVW'[i]
                set_text(self.relative[d], fmt % (letter, relp[i]))
                set_text(self.absolute[d], h + fmt % (letter, p[i]))
                set_text(self.distance[d], fmt % (letter, dtg[i]))
                d += 1

        estopped = self.emcstat.task_state == self.emc.STATE_ESTOP
        set_active(self.estops['estop'], estopped)
        set_active(self.estops['estop_reset'], not estopped)

        on = self.emcstat.task_state == self.emc.STATE_ON
        set_active(self.machines['on'], on)
        set_active(self.machines['off'], not on)

        ovl = self.emcstat.axis[0]['override_limits']
        set_active(self.override_limit, ovl)

        set_text(self.status['file'], self.emcstat.file)
        set_text(self.status['line'], "%d" % self.emcstat.current_line)
        set_text(self.status['id'], "%d" % self.emcstat.id)
        set_text(self.status['dtg'], "%f" % self.emcstat.distance_to_go)
        set_text(self.status['velocity'],
                 "%f" % (self.emcstat.current_vel * 60.0))
        set_text(self.status['delay'], "%f" % self.emcstat.delay_left)

        flood = self.emcstat.flood
        set_active(self.floods['on'], flood)
        set_active(self.floods['off'], not flood)

        mist = self.emcstat.mist
        set_active(self.mists['on'], mist)
        set_active(self.mists['off'], not mist)

        spin = self.emcstat.spindle_direction
        set_active(self.spindles['forward'], spin == 1)
        set_active(self.spindles['off'], spin == 0)
        set_active(self.spindles['reverse'], spin == -1)

        ol = ""
        for i in range(len(self.emcstat.limit)):
            if self.emcstat.limit[i]:
                ol += "%c " % "XYZABCUVW"[i]
        set_text(self.status['onlimit'], ol)

        sd = (_("CCW"), _("Stopped"), _("CW"))
        set_text(self.status['spindledir'],
                 sd[self.emcstat.spindle_direction + 1])

        set_text(self.status['spindlespeed'],
                 "%d" % self.emcstat.spindle_speed)
        set_text(self.status['loadedtool'],
                 "%d" % self.emcstat.tool_in_spindle)
        if self.emcstat.pocket_prepped == -1:
            set_text(self.status['preppedtool'], _("None"))
        else:
            set_text(
                self.status['preppedtool'],
                "%d" % self.emcstat.tool_table[self.emcstat.pocket_prepped].id)
        set_text(self.status['xyrotation'], "%d" % self.emcstat.rotation_xy)
        set_text(self.status['tlo'], "%f" % self.emcstat.tool_offset[2])

        active_codes = []
        for i in self.emcstat.gcodes[1:]:
            if i == -1: continue
            if i % 10 == 0:
                active_codes.append("G%d" % (i / 10))
            else:
                active_codes.append("G%d.%d" % (i / 10, 1 % 10))

        for i in self.emcstat.mcodes[1:]:
            if i == -1: continue
            active_codes.append("M%d" % i)

        feed_str = "F%.1f" % self.emcstat.settings[1]
        if feed_str.endswith(".0"): feed_str = feed_str[:-2]
        active_codes.append(feed_str)
        active_codes.append("S%.0f" % self.emcstat.settings[2])

        set_text(self.status['activecodes'], " ".join(active_codes))

        set_active(self.prefs['inch'], self.mm == 0)
        set_active(self.prefs['mm'], self.mm == 1)
        set_active(self.prefs['actual'], self.actual == 1)
        set_active(self.prefs['commanded'], self.actual == 0)

        set_active(self.opstop['on'], self.emcstat.optional_stop)
        set_active(self.opstop['off'], not self.emcstat.optional_stop)

        set_active(self.blockdel['on'], self.emcstat.block_delete)
        set_active(self.blockdel['off'], not self.emcstat.block_delete)

        if self.emcstat.id == 0 and (
                self.emcstat.interp_state == self.emc.INTERP_PAUSED
                or self.emcstat.exec_state == self.emc.EXEC_WAITING_FOR_DELAY):
            self.listing.highlight_line(self.emcstat.current_line)
        elif self.emcstat.id == 0:
            self.listing.highlight_line(self.emcstat.motion_line)
        else:
            self.listing.highlight_line(self.emcstat.id
                                        or self.emcstat.motion_line)

        e = self.emcerror.poll()
        if e:
            kind, text = e
            set_text(self.error, text)