File: qtvcp_handler.py

package info (click to toggle)
linuxcnc 1%3A2.9.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 285,604 kB
  • sloc: python: 202,568; ansic: 109,036; cpp: 99,239; tcl: 16,054; xml: 10,631; sh: 10,303; makefile: 1,255; javascript: 138; sql: 72; asm: 15
file content (51 lines) | stat: -rw-r--r-- 1,400 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import linuxcnc

# Set up logging
from . import logger

log = logger.getLogger(__name__)


# Set the log level for this module
# log.setLevel(logger.INFO) # One of DEBUG, INFO, WARNING, ERROR, CRITICAL

class HandlerClass:

    # This will be pretty standard to gain access.
    # widgets allows access to  widgets from the qtvcp files
    # at this point the widgets and hal pins are not instantiated
    def __init__(self, halcomp, widgets):
        self.hal = halcomp
        self.w = widgets
        self.stat = linuxcnc.stat()
        self.cmnd = linuxcnc.command()

    def initialized__(self):
        log.debug('INIT qtvcp handler')

    def halbuttonclicked(self):
        log.debug('click')

    def estop_toggled(self, pressed):
        log.debug('estop click {}'.format(pressed))
        if pressed:
            self.cmnd.state(linuxcnc.STATE_ESTOP_RESET)
        else:
            self.cmnd.state(linuxcnc.STATE_ESTOP)

    def machineon_toggled(self, pressed):
        log.debug('machine on click {}'.format(pressed))
        if pressed:
            self.cmnd.state(linuxcnc.STATE_ON)
        else:
            self.cmnd.state(linuxcnc.STATE_OFF)

    def home_clicked(self):
        log.debug('home click')
        self.cmnd.mode(linuxcnc.MODE_MANUAL)
        self.cmnd.home(-1)


# standard handler call
def get_handlers(halcomp, widgets):
    return [HandlerClass(halcomp, widgets)]