Fix toolbar icon status on socket error

This commit is contained in:
Ken Roberts 2014-10-15 11:41:12 -07:00
parent dc321155a0
commit 5879209627
2 changed files with 14 additions and 13 deletions

View File

@ -218,19 +218,19 @@ class PJLink1(QTcpSocket):
self.timer.start() self.timer.start()
for command in ['POWR', 'ERST', 'LAMP', 'AVMT', 'INPT']: for command in ['POWR', 'ERST', 'LAMP', 'AVMT', 'INPT']:
# Changeable information # Changeable information
self.send_command(command) self.send_command(command, queue=True)
if self.power == S_ON and self.source_available is None: if self.power == S_ON and self.source_available is None:
self.send_command('INST') self.send_command('INST', queue=True)
if self.other_info is None: if self.other_info is None:
self.send_command('INFO') self.send_command('INFO', queue=True)
if self.manufacturer is None: if self.manufacturer is None:
self.send_command('INF1') self.send_command('INF1', queue=True)
if self.model is None: if self.model is None:
self.send_command('INF2') self.send_command('INF2', queue=True)
if self.pjlink_name is None: if self.pjlink_name is None:
self.send_command('NAME') self.send_command('NAME', queue=True)
if self.power == S_ON and self.source_available is None: if self.power == S_ON and self.source_available is None:
self.send_command('INST') self.send_command('INST', queue=True)
def _get_status(self, status): def _get_status(self, status):
""" """
@ -422,7 +422,7 @@ class PJLink1(QTcpSocket):
self.projectorUpdateIcons.emit() self.projectorUpdateIcons.emit()
return return
def send_command(self, cmd, opts='?', salt=None): def send_command(self, cmd, opts='?', salt=None, queue=False):
""" """
Add command to output queue if not already in queue Add command to output queue if not already in queue
""" """
@ -442,12 +442,11 @@ class PJLink1(QTcpSocket):
if out in self.send_queue: if out in self.send_queue:
# Already there, so don't add # Already there, so don't add
log.debug('(%s) send_command(out=%s) Already in queue - skipping' % (self.ip, out.strip())) log.debug('(%s) send_command(out=%s) Already in queue - skipping' % (self.ip, out.strip()))
elif len(self.send_queue) == 0: elif not queue and len(self.send_queue) == 0 and not self.send_busy:
return self._send_string(out) return self._send_string(out)
else: else:
self.send_queue.append(out) self.send_queue.append(out)
if not self.send_busy: self.projectorReceivedData.emit()
self._send_string()
@pyqtSlot() @pyqtSlot()
def _send_command(self): def _send_command(self):
@ -701,6 +700,7 @@ class PJLink1(QTcpSocket):
""" """
if self.state() != self.ConnectedState: if self.state() != self.ConnectedState:
log.warn('(%s) disconnect_from_host(): Not connected - returning' % self.ip) log.warn('(%s) disconnect_from_host(): Not connected - returning' % self.ip)
self.projectorUpdateIcons.emit()
return return
self.disconnectFromHost() self.disconnectFromHost()
try: try:
@ -709,6 +709,7 @@ class PJLink1(QTcpSocket):
pass pass
self.change_status(S_NOT_CONNECTED) self.change_status(S_NOT_CONNECTED)
self.reset_information() self.reset_information()
self.projectorUpdateIcons.emit()
def get_available_inputs(self): def get_available_inputs(self):
""" """

View File

@ -850,8 +850,8 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
self.get_toolbar_item('delete_projector', enabled=True) self.get_toolbar_item('delete_projector', enabled=True)
self.get_toolbar_item('connect_projector', enabled=not connected) self.get_toolbar_item('connect_projector', enabled=not connected)
self.get_toolbar_item('disconnect_projector', enabled=connected) self.get_toolbar_item('disconnect_projector', enabled=connected)
self.get_toolbar_item('poweron_projector', enabled=projector.link.power == S_STANDBY) self.get_toolbar_item('poweron_projector', enabled=connected and (projector.link.power == S_STANDBY))
self.get_toolbar_item('poweroff_projector', enabled=projector.link.power == S_ON) self.get_toolbar_item('poweroff_projector', enabled=connected and (projector.link.power == S_ON))
if projector.link.shutter is not None: if projector.link.shutter is not None:
self.get_toolbar_item('blank_projector', enabled=(connected and power and not projector.link.shutter)) self.get_toolbar_item('blank_projector', enabled=(connected and power and not projector.link.shutter))
self.get_toolbar_item('show_projector', enabled=(connected and power and projector.link.shutter)) self.get_toolbar_item('show_projector', enabled=(connected and power and projector.link.shutter))