Fix source select when sources not known yet

This commit is contained in:
Ken Roberts 2014-10-15 13:53:17 -07:00
parent e4926416f8
commit f60f8d211b
2 changed files with 12 additions and 5 deletions

View File

@ -475,17 +475,17 @@ class PJLink1(QTcpSocket):
return return
if data is not None: if data is not None:
out = data out = data
log.debug('(%s) _send_string(data=%s)' % (self.ip, out)) log.debug('(%s) _send_string(data=%s)' % (self.ip, out.strip()))
elif len(self.send_queue) != 0: elif len(self.send_queue) != 0:
out = self.send_queue.pop(0) out = self.send_queue.pop(0)
log.debug('(%s) _send_string(queued data=%s)' % (self.ip, out)) log.debug('(%s) _send_string(queued data=%s)' % (self.ip, out.strip()))
else: else:
# No data to send # No data to send
log.debug('(%s) _send_string(): No data to send' % self.ip) log.debug('(%s) _send_string(): No data to send' % self.ip)
self.send_busy = False self.send_busy = False
return return
self.send_busy = True self.send_busy = True
log.debug('(%s) _send_string(): Sending "%s"' % (self.ip, out)) log.debug('(%s) _send_string(): Sending "%s"' % (self.ip, out.strip()))
log.debug('(%s) _send_string(): Queue = %s' % (self.ip, self.send_queue)) log.debug('(%s) _send_string(): Queue = %s' % (self.ip, self.send_queue))
try: try:
self.projectorNetwork.emit(S_NETWORK_SENDING) self.projectorNetwork.emit(S_NETWORK_SENDING)
@ -550,7 +550,12 @@ class PJLink1(QTcpSocket):
lamps = [] lamps = []
data_dict = data.split() data_dict = data.split()
while data_dict: while data_dict:
try:
fill = {'Hours': int(data_dict[0]), 'On': False if data_dict[1] == '0' else True} fill = {'Hours': int(data_dict[0]), 'On': False if data_dict[1] == '0' else True}
except ValueError:
# In case of invalid entry
log.warn('(%s) process_lamp(): Invalid data "%s"' %( self.ip, data))
return
lamps.append(fill) lamps.append(fill)
data_dict.pop(0) # Remove lamp hours data_dict.pop(0) # Remove lamp hours
data_dict.pop(0) # Remove lamp on/off data_dict.pop(0) # Remove lamp on/off
@ -653,6 +658,7 @@ class PJLink1(QTcpSocket):
for source in check: for source in check:
sources.append(source) sources.append(source)
self.source_available = sources self.source_available = sources
self.projectorUpdateIcons.emit()
return return
def process_erst(self, data): def process_erst(self, data):

View File

@ -841,7 +841,8 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa
power = projector.link.power == S_ON power = projector.link.power == S_ON
if connected: if connected:
self.get_toolbar_item('view_projector', enabled=True) self.get_toolbar_item('view_projector', enabled=True)
self.get_toolbar_item('source_projector', enabled=connected & power) self.get_toolbar_item('source_projector',
enabled=connected and power and projector.link.source_available is not None)
self.get_toolbar_item('edit_projector', hidden=True) self.get_toolbar_item('edit_projector', hidden=True)
self.get_toolbar_item('delete_projector', hidden=True) self.get_toolbar_item('delete_projector', hidden=True)
else: else: