From 72cca862080243a85f0d3dc92c15072227e1a9ad Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Mon, 13 Oct 2014 07:51:23 -0700 Subject: [PATCH] Refactor pjlink/remove db id in view projector/add pjlink command to constants --- openlp/core/lib/projector/constants.py | 3 ++- openlp/core/lib/projector/pjlink1.py | 25 ++++++++++++++----------- openlp/core/ui/projector/manager.py | 14 +++++++++----- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/openlp/core/lib/projector/constants.py b/openlp/core/lib/projector/constants.py index 72903f45f..eec17bf47 100644 --- a/openlp/core/lib/projector/constants.py +++ b/openlp/core/lib/projector/constants.py @@ -61,7 +61,8 @@ LF = chr(0x0A) # \n PJLINK_PORT = 4352 TIMEOUT = 30.0 PJLINK_MAX_PACKET = 136 -PJLINK_VALID_CMD = {'1': ['POWR', # Power option +PJLINK_VALID_CMD = {'1': ['PJLINK', # Initial connection + 'POWR', # Power option 'INPT', # Video sources option 'AVMT', # Shutter option 'ERST', # Error status option diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index e557839d6..e6d63362f 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -128,17 +128,7 @@ class PJLink1(QTcpSocket): self.setReadBufferSize(self.maxSize) # PJLink projector information self.pjlink_class = '1' # Default class - self.power = S_OFF - self.pjlink_name = None - self.manufacturer = None - self.model = None - self.shutter = None - self.mute = None - self.lamp = None - self.fan = None - self.source_available = None - self.source = None - self.projector_errors = None + self.reset_information() # Set from ProjectorManager.add_projector() self.widget = None # QListBox entry self.timer = None # Timer that calls the poll_loop @@ -156,6 +146,19 @@ class PJLink1(QTcpSocket): 'POWR': self.process_powr } + def reset_information(self): + self.power = S_OFF + self.pjlink_name = None + self.manufacturer = None + self.model = None + self.shutter = None + self.mute = None + self.lamp = None + self.fan = None + self.source_available = None + self.source = None + self.projector_errors = None + def thread_started(self): """ Connects signals to methods when thread is started. diff --git a/openlp/core/ui/projector/manager.py b/openlp/core/ui/projector/manager.py index 6012ab693..e62a2b4f2 100644 --- a/openlp/core/ui/projector/manager.py +++ b/openlp/core/ui/projector/manager.py @@ -60,7 +60,8 @@ STATUS_ICONS = {S_NOT_CONNECTED: ':/projector/projector_item_disconnect.png', E_ERROR: ':/projector/projector_error.png', E_NETWORK: ':/projector/projector_not_connected.png', E_AUTHENTICATION: ':/projector/projector_not_connected.png', - E_UNKNOWN_SOCKET_ERROR: ':/icons/openlp-logo-64x64.png' + E_UNKNOWN_SOCKET_ERROR: ':/icons/openlp-logo-64x64.png', + E_NOT_CONNECTED: ':/projector/projector_not_connected.png' } @@ -730,10 +731,9 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa notes = translate('OpenLP.ProjectorManager', 'Notes') QtGui.QMessageBox.information(self, translate('OpenLP.ProjectorManager', 'Projector %s Information' % projector.link.name), - '%s: %s

%s: %s

%s: %s

' + '
%s: %s

%s: %s

' '%s: %s

%s: %s

' - '%s:
%s' % (dbid, projector.link.dbid, - ip, projector.link.ip, + '%s:
%s' % (ip, projector.link.ip, port, projector.link.port, name, projector.link.name, location, projector.link.location, @@ -890,7 +890,11 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ProjectorMa log.debug('(%s) updateStatus(status=%s) message: "%s"' % (item.link.name, status_code, message)) if status in STATUS_ICONS: item.icon = QtGui.QIcon(QtGui.QPixmap(STATUS_ICONS[status])) - log.debug('(%s) Updating icon' % item.link.name) + if status in ERROR_STRING: + status_code = ERROR_STRING[status] + elif status in STATUS_STRING: + status_code = STATUS_STRING[status] + log.debug('(%s) Updating icon with %s' % (item.link.name, status_code)) item.widget.setIcon(item.icon) @pyqtSlot()