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()
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()