コード例 #1
0
def test_halremote_integration(halremote, dns_sd):
    rcomp = halremote.RemoteComponent('test')
    rcomp.newpin('foo', halremote.HAL_BIT, halremote.HAL_OUT)
    rcomp.newpin('bar', halremote.HAL_FLOAT, halremote.HAL_IN)

    sd = dns_sd.ServiceDiscovery()
    sd.register(rcomp)
コード例 #2
0
ファイル: ncurses.py プロジェクト: yazici/pymachinetalk
    def __init__(self, uuid, use_curses, debug=False):
        sd_filter = ServiceDiscoveryFilter(txt_records={'uuid': uuid})
        self.sd = ServiceDiscovery(filter_=sd_filter)

        halrcomp = halremote.component('test')
        halrcomp.debug = debug
        halrcomp.newpin("coolant-iocontrol", halremote.HAL_BIT, halremote.HAL_IN)
        halrcomp.newpin("coolant", halremote.HAL_BIT, halremote.HAL_OUT)
        self.halrcomp = halrcomp
        self.sd.register(halrcomp)

        halrcomp2 = halremote.RemoteComponent(name='test2', debug=debug)
        halrcomp2.newpin("coolant-iocontrol", halremote.HAL_BIT, halremote.HAL_IN)
        halrcomp2.newpin("coolant", halremote.HAL_BIT, halremote.HAL_OUT)
        self.halrcomp2 = halrcomp2
        self.sd.register(halrcomp2)

        self.status = ApplicationStatus(debug=debug)
        self.status.on_synced_changed.append(self._on_status_synced)
        self.sd.register(self.status)
        self.command = ApplicationCommand(debug=debug)
        self.sd.register(self.command)
        self.error = ApplicationError(debug=debug)
        self.sd.register(self.error)
        self.fileservice = ApplicationFile(debug=debug)
        self.fileservice.local_file_path = 'test.ngc'
        self.fileservice.local_path = './ngc/'
        self.fileservice.remote_path = '/home/xy/'
        self.fileservice.remote_file_path = '/home/xy/test.ngc'
        self.fileservice.on_ready_changed.append(self._on_fileservice_ready)
        self.sd.register(self.fileservice)

        self.timer = None
        self.timer_interval = 0.1

        self.use_curses = use_curses
        if not self.use_curses:
            return

        self.messages = []

        self.screen = curses.initscr()
        self.screen.keypad(True)
        self.dro_window = curses.newwin(10, 40, 1, 2)
        self.status_window = curses.newwin(10, 40, 1, 44)
        self.command_window = curses.newwin(10, 40, 1, 86)
        self.connection_window = curses.newwin(10, 80, 12, 2)
        self.error_window = curses.newwin(20, 120, 12, 84)
        self.file_window = curses.newwin(10, 80, 1, 108)
        curses.noecho()
        curses.cbreak()
コード例 #3
0
    def __init__(self):
        self.sd = ServiceDiscovery()

        rcomp = halremote.RemoteComponent('anddemo', debug=False)
        rcomp.no_create = True
        rcomp.newpin('button0', halremote.HAL_BIT, halremote.HAL_OUT)
        rcomp.newpin('button1', halremote.HAL_BIT, halremote.HAL_OUT)
        led_pin = rcomp.newpin('led', halremote.HAL_BIT, halremote.HAL_IN)
        led_pin.on_value_changed.append(self.led_pin_changed)
        led_pin.on_synced_changed.append(self.led_pin_synced)
        rcomp.on_connected_changed.append(self._connected)

        self.halrcomp = rcomp
        self.sd.register(rcomp)
コード例 #4
0
ファイル: halremote.py プロジェクト: tweakoz/pymachinetalk
    def run(self):
        timeout = 2.0

        launcher_sd = ServiceDiscovery(
            service_type="_launcher._sub._machinekit._tcp", debug=True)
        print('starting launcher service discovery')
        launcher_sd.start()
        assert launcher_sd.wait_discovered(timeout)
        data = launcher_sd.service_names.values()[0]
        print('launcher discovered %s %s' % (data.name, data.dsn))
        uuid = data.uuid
        print('uuid=%s' % uuid)

        halrcmd_sd = ServiceDiscovery(
            service_type="_halrcmd._sub._machinekit._tcp",
            uuid=uuid,
            debug=True)
        print('starting halrcmd service discovery')
        halrcmd_sd.start()
        assert halrcmd_sd.wait_discovered(timeout)
        data = halrcmd_sd.service_names.values()[0]
        print('halrcmd discovered %s %s' % (data.name, data.dsn))
        halrcmd_dsn = data.dsn

        halrcomp_sd = ServiceDiscovery(
            service_type="_halrcomp._sub._machinekit._tcp",
            uuid=uuid,
            debug=True)
        print('starting halrcomp service discovery')
        halrcomp_sd.start()
        assert halrcomp_sd.wait_discovered(timeout)
        data = halrcomp_sd.service_names.values()[0]
        print('halrcomp discovered %s %s' % (data.name, data.dsn))
        halrcomp_dsn = data.dsn

        halrcomp = halremote.RemoteComponent('anddemo')
        halrcomp.newpin('button0', halremote.HAL_BIT, halremote.HAL_OUT)
        halrcomp.newpin('button1', halremote.HAL_BIT, halremote.HAL_OUT)
        halrcomp.newpin('led', halremote.HAL_BIT, halremote.HAL_IN)
        #halrcomp.no_create = True
        halrcomp.halrcomp_uri = halrcomp_dsn
        halrcomp.halrcmd_uri = halrcmd_dsn

        halrcomp.ready()
        print('waiting for component connected')
        assert halrcomp.wait_connected()
        print('component connected')
        halrcomp.stop()

        self.loop.quit()
コード例 #5
0
ファイル: anddemo.py プロジェクト: tweakoz/pymachinetalk
    def __init__(self):
        launcher_sd = ServiceDiscovery(
            service_type="_launcher._sub._machinekit._tcp")
        launcher_sd.on_discovered.append(self.service_discovered)
        launcher_sd.on_disappeared.append(self.service_disappeared)
        launcher_sd.start()
        self.launcher_sd = launcher_sd

        self.halrcompReady = False
        self.halrcmdReady = False
        halrcomp = halremote.RemoteComponent('anddemo')
        halrcomp.newpin('button0', halremote.HAL_BIT, halremote.HAL_OUT)
        halrcomp.newpin('button1', halremote.HAL_BIT, halremote.HAL_OUT)
        halrcomp.newpin('led', halremote.HAL_BIT, halremote.HAL_IN)
        halrcomp.no_create = True
        self.halrcomp = halrcomp
コード例 #6
0
    def run(self):
        timeout = 2.0

        sd = ServiceDiscovery()
        halrcomp = halremote.RemoteComponent('anddemo')
        halrcomp.newpin('button0', halremote.HAL_BIT, halremote.HAL_OUT)
        halrcomp.newpin('button1', halremote.HAL_BIT, halremote.HAL_OUT)
        halrcomp.newpin('led', halremote.HAL_BIT, halremote.HAL_IN)
        sd.register(halrcomp)

        sd.start()
        print('waiting for component connected')
        assert halrcomp.wait_connected(timeout)
        print('component connected')
        print('stopping service discovery')
        sd.stop()
        print('completed')
コード例 #7
0
    def __init__(self, com_pin=board.D18, num_pixels=16, debug=False):
        self.pixels = neopixel.NeoPixel(com_pin, num_pixels)
        self._connected = False
        self._enabled = False
        self._update_light()

        rcomp = halremote.RemoteComponent('neopixel', debug=debug)
        rcomp.no_create = True
        enable_pin = rcomp.newpin('enable', halremote.HAL_BIT,
                                  halremote.HAL_IN)
        enable_pin.on_value_changed.append(self._enable_pin_changed)
        mode_pin = rcomp.newpin('mode', halremote.HAL_U32, halremote.HAL_IN)
        mode_pin.on_value_changed.append(self._mode_pin_changed)
        rcomp.on_connected_changed.append(self._connected_changed)

        self.rcomp = rcomp
        self.sd = ServiceDiscovery(filter_=ServiceDiscoveryFilter(
            txt_records={b'uuid': MK_UUID}))
        self.sd.register(rcomp)
コード例 #8
0
ファイル: main.py プロジェクト: yazici/fusion360-machinekit
    def __init__(self):
        self.sd = ServiceDiscovery(nameservers=['192.168.7.2'])

        rcomp = halremote.RemoteComponent('command-interface', debug=False)
        rcomp.no_create = False
        for i in range(MAX_AXES):
            rcomp.newpin('joint%i.position-cmd' % i, halremote.HAL_FLOAT,
                         halremote.HAL_OUT)
            rcomp.newpin('joint%i.position-fb' % i, halremote.HAL_FLOAT,
                         halremote.HAL_IN)
            rcomp.newpin('joint%i.enable' % i, halremote.HAL_BIT,
                         halremote.HAL_IO)
            rcomp.newpin('joint%i.position-max' % i, halremote.HAL_FLOAT,
                         halremote.HAL_IO)
            rcomp.newpin('joint%i.position-min' % i, halremote.HAL_FLOAT,
                         halremote.HAL_IO)
        rcomp.on_connected_changed.append(self._connected)

        self.halrcomp = rcomp
        self.sd.register(rcomp)
コード例 #9
0
ファイル: ncurses.py プロジェクト: tweakoz/pymachinetalk
    def __init__(self, uuid, use_curses):
        self.halrcmdReady = False
        self.halrcompReady = False

        halrcomp = halremote.component('test')
        halrcomp.newpin("coolant-iocontrol", halremote.HAL_BIT,
                        halremote.HAL_IN)
        halrcomp.newpin("coolant", halremote.HAL_BIT, halremote.HAL_OUT)
        self.halrcomp = halrcomp

        halrcomp2 = halremote.RemoteComponent(name='test2')
        halrcomp2.newpin("coolant-iocontrol", halremote.HAL_BIT,
                         halremote.HAL_IN)
        halrcomp2.newpin("coolant", halremote.HAL_BIT, halremote.HAL_OUT)
        self.halrcomp2 = halrcomp2

        self.status = ApplicationStatus()
        self.command = ApplicationCommand()
        self.error = ApplicationError()
        self.fileservice = ApplicationFile()
        self.fileservice.local_file_path = 'test.ngc'
        self.fileservice.local_path = './ngc/'
        self.fileservice.remote_path = '/home/xy/'
        self.fileservice.remote_file_path = '/home/xy/test.ngc'

        halrcmd_sd = ServiceDiscovery(
            service_type="_halrcmd._sub._machinekit._tcp", uuid=uuid)
        halrcmd_sd.on_discovered.append(self.halrcmd_discovered)
        halrcmd_sd.start()
        #halrcmd_sd.disappered_callback = disappeared
        self.halrcmd_sd = halrcmd_sd

        halrcomp_sd = ServiceDiscovery(
            service_type="_halrcomp._sub._machinekit._tcp", uuid=uuid)
        halrcomp_sd.on_discovered.append(self.halrcomp_discovered)
        halrcomp_sd.start()
        self.harcomp_sd = halrcomp_sd

        status_sd = ServiceDiscovery(
            service_type="_status._sub._machinekit._tcp", uuid=uuid)
        status_sd.on_discovered.append(self.status_discovered)
        status_sd.on_disappeared.append(self.status_disappeared)
        status_sd.start()
        self.status_sd = status_sd

        command_sd = ServiceDiscovery(
            service_type="_command._sub._machinekit._tcp", uuid=uuid)
        command_sd.on_discovered.append(self.command_discovered)
        command_sd.on_disappeared.append(self.command_disappeared)
        command_sd.start()

        error_sd = ServiceDiscovery(
            service_type="_error._sub._machinekit._tcp", uuid=uuid)
        error_sd.on_discovered.append(self.error_discovered)
        error_sd.on_disappeared.append(self.error_disappeared)
        error_sd.start()

        file_sd = ServiceDiscovery(service_type="_file._sub._machinekit._tcp",
                                   uuid=uuid)
        file_sd.on_discovered.append(self.file_discovered)
        file_sd.on_disappeared.append(self.file_disappeared)
        file_sd.start()

        self.timer = None

        self.use_curses = use_curses
        if not self.use_curses:
            return

        self.messages = []

        self.screen = curses.initscr()
        self.screen.keypad(True)
        self.dro_window = curses.newwin(10, 40, 1, 2)
        self.status_window = curses.newwin(10, 40, 1, 44)
        self.command_window = curses.newwin(10, 40, 1, 86)
        self.connection_window = curses.newwin(10, 80, 12, 2)
        self.error_window = curses.newwin(20, 120, 12, 84)
        self.file_window = curses.newwin(10, 80, 1, 108)
        curses.noecho()
        curses.cbreak()