コード例 #1
0
    def setupUi(self):
        super(TelemetryLayer, self).setupUi(self)
        self.dockWidget.setFixedHeight(self.height())  # paramterise
        self.dockWidget.setFeatures(QtGui.QDockWidget.DockWidgetClosable)
        self.dockWidget.setWindowTitle(_translate("tlBrokerConfig", "Configure Telemetry Layer", None))
        self.ckShowLog.clicked.connect(self._showLog)

        # Nathan - Use setChecked(bool) to make it easier
        self.ckShowLog.setCheckState(self._getQtBoxStateValue(Log.logDockVisible()))

        self.dockWidget.visibilityChanged.connect(self._visibilityChanged)

        self.btnApply.clicked.connect(self._apply)
        self.btnAdd.clicked.connect(self._addBroker)

        logStates = int(Settings.get('logStates', Log.CRITICAL))

        # Nathan - The checked state conversion isn't needed
        # Just call setChecked(bool)
        # Also consider using a QButtonGroup here in order to have only one button pressed at a time.
        self.logCritical.setCheckState(self._getQtBoxStateValue(logStates & Log.CRITICAL))
        self.logInfo.setCheckState(self._getQtBoxStateValue(logStates & Log.INFO))
        self.logWarn.setCheckState(self._getQtBoxStateValue(logStates & Log.WARN))
        self.logDebug.setCheckState(self._getQtBoxStateValue(logStates & Log.DEBUG))
        self.logStatus.setCheckState(self._getQtBoxStateValue(logStates & Log.STATUS))
        self.brokerManagerWidget.setCurrentIndex(self.kBrokerListTabId)
        self._buildBrokerTable()
コード例 #2
0
def is_changed(values, feature, parent):
    result = 0
    try:
        result = (int(time.time()) - int(feature['changed'])) < int(Settings.get('changedTimeout', 25))
    except (KeyError, TypeError):
        return 0
    finally:
        return result
コード例 #3
0
    def __init__(self, broker, create=False):
        super(tlTopicManager, self).__init__()

        self._broker = broker
        self._create = create

        systopicxml = os.path.join(Settings.get('plugin_dir'), 'data', 'systopics.xml')

        self._systopics = XMLTopicParser(systopicxml).getTopics()
コード例 #4
0
    def __init__(self, pluginDir):
        super(tlBrokers, self).__init__()
        self._jsonfile = None
        self._loaded = False
        self._dirty = False
        self._brokers = {}
        self._oldBrokers = None
        self._dirty = False
        self._dirtyList = []
        self._defaultFile = os.path.join(pluginDir, self.kDefaultFile)
        self._jsonfile = Settings.get("brokerFile", self._defaultFile)
        tlBrokers._this = self
        QgsProject.instance().readProject.connect(self.load)

        self.load()
コード例 #5
0
ファイル: tlbrokers.py プロジェクト: nzfarmer1/telemetrylayer
    def __init__(self, pluginDir):
        super(tlBrokers, self).__init__()
        self._jsonfile = None
        self._loaded = False
        self._dirty = False
        self._brokers = {}
        self._oldBrokers = None
        self._dirty = False
        self._dirtyList = []
        self._defaultFile = os.path.join(pluginDir, self.kDefaultFile)
        self._jsonfile = Settings.get("brokerFile", self._defaultFile)
        tlBrokers._this = self
        QgsProject.instance().readProject.connect(self.load)

        self.load()
コード例 #6
0
ファイル: tlbrokers.py プロジェクト: nzfarmer1/telemetrylayer
    def load(self):
        try:
            jsonstr = Settings.get(self.kBrokerList)
            if not jsonstr:
               Log.debug("Load brokers from file") 
               self._brokers = dict(self.importFile()) # backward compatible
            else:
               self._brokers = dict(json.loads( jsonstr ))

            self._validate()
            #Log.debug(self._dirtyList)
            self.brokersLoaded.emit(self._dirtyList)
            self._dirtyList[:] = []
        except Exception as e:
            Log.debug("Error loading broker: " + str(e))
            exc_type, exc_value, exc_traceback = sys.exc_info()
            Log.debug(repr(traceback.format_exception(exc_type, exc_value,
                                                      exc_traceback)))
        finally:
            self._dirty = False
コード例 #7
0
    def setupUi(self):
        super(TelemetryLayer, self).setupUi(self)
        self.dockWidget.setFixedHeight(self.height())  # paramterise
        self.dockWidget.setFeatures(QtGui.QDockWidget.DockWidgetClosable)
        self.dockWidget.setWindowTitle(_translate("tlBrokerConfig", "Configure Telemetry Layer", None))
        self.ckShowLog.clicked.connect(self._showLog)
        self.ckShowLog.setChecked(Log.logDockVisible())

        self.dockWidget.visibilityChanged.connect(self._visibilityChanged)

        self.btnApply.clicked.connect(self._apply)
        self.btnAdd.clicked.connect(self._addBroker)

        logStates = int(Settings.get('logStates', Log.CRITICAL))

        self.logCritical.setChecked(logStates & Log.CRITICAL)
        self.logInfo.setChecked(logStates & Log.INFO)
        self.logWarn.setChecked(logStates & Log.WARN)
        self.logDebug.setChecked(logStates & Log.DEBUG)
        self.logStatus.setChecked(logStates & Log.STATUS)
        self.brokerManagerWidget.setCurrentIndex(self.kBrokerListTabId)
        self._buildBrokerTable()
コード例 #8
0
    def load(self):
        try:
            jsonstr = Settings.get(self.kBrokerList)
            if not jsonstr:
                Log.debug("Load brokers from file")
                self._brokers = dict(self.importFile())  # backward compatible
            else:
                self._brokers = dict(json.loads(jsonstr))

            self._validate()
            #Log.debug(self._dirtyList)
            self.brokersLoaded.emit(self._dirtyList)
            self._dirtyList[:] = []
        except Exception as e:
            Log.debug("Error loading broker: " + str(e))
            exc_type, exc_value, exc_traceback = sys.exc_info()
            Log.debug(
                repr(
                    traceback.format_exception(exc_type, exc_value,
                                               exc_traceback)))
        finally:
            self._dirty = False
コード例 #9
0
    def setupUi(self):
        super(tlBrokerConfig, self).setupUi(self)

        self.connectHelp.clicked.connect(self._help)
        self.connectTest.clicked.connect(self._test)

        self.connectName.setValidator(QRegExpValidator(QRegExp("^[a-zA-Z0-9\s]+"), self))
        self.connectHost.setValidator(QRegExpValidator(QRegExp("^[a-z0-9\-\.]+"), self))
        self.connectHostAlt.setValidator(QRegExpValidator(QRegExp("^[a-z0-9\-\.]+"), self))

        
        self.Tabs.setCurrentIndex(self.kBrokerConfigTabId)  # First index
        


        # if Modal create mode
        self.setName(self._broker.name())
        self.setHost(self._broker.host())
        self.setPort(str(self._broker.port()))

        self.setHostAlt(self._broker.hostAlt())
        self.setPortAlt(str(self._broker.portAlt()))

        self.setPoll(str(self._broker.poll()))
        self.setKeepAlive(str(self._broker.keepAlive()))

        self.setUsername(self._broker.username())   
        self.setPassword(self._broker.password())

        self._connectedTLayers = []
        self._featureListItems = {}
        self._refreshFeature = QTimer()
        self._refreshFeature.setSingleShot(True)
        self._refreshFeature.timeout.connect(self._updateFeatureList)
        self.Tabs.currentChanged.connect(lambda: self._refreshFeature.start(3))
        QgsMapLayerRegistry.instance().layersRemoved.connect(self._updateFeatureList)
        QgsProject.instance().layerLoaded.connect(self._updateFeatureList)
        
        self.tableFeatureList.doubleClicked.connect(self._showFeatureDialog)
        self.tableFeatureList.clicked.connect(self._zoomToFeature)

        self.connectApply.setEnabled(False)


        if self._mode == Constants.Create:  # Create Layer - so Modal
            self.connectPoll.setCurrentIndex(
                self.connectPoll.findText(Settings.get('mqttPoll', 5)))
            self.connectApply.setText(_translate("tlBrokerConfig", "Create", None))
            self.connectApply.clicked.connect(self.accept)
            self.dockWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
            self.dockWidget.setWindowTitle(_translate("tlBrokerConfig", "Add Broker", None))
            #self.Tabs.setEnabled(False)
            #   self.connectFarmSenseServer.setEnabled(False)
        elif self._mode == Constants.Update:
            
            if self._broker.useAltConnect():
                self.connectDefault.setChecked(False)
                self.connectAlt.setChecked(True)
            else:
                self.connectDefault.setChecked(True)
                self.connectAlt.setChecked(False)

            self.dockWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
            self.dockWidget.setWindowTitle(_translate("tlBrokerConfig", "Configure ", None) + self.getName())
            self.connectApply.setText(_translate("tlBrokerConfig", "Apply", None))
            self.dockWidget.visibilityChanged.connect(self.tearDown)


        self.connectName.textChanged.connect(lambda: self.setDirty(True))
        self.connectHost.textChanged.connect(lambda: self.setDirty(True))
        self.connectPort.textChanged.connect(lambda: self.setDirty(True))
        self.connectHostAlt.textChanged.connect(lambda: self.setDirty(True))
        self.connectPortAlt.textChanged.connect(lambda: self.setDirty(True))
        self.connectUsername.textChanged.connect(lambda: self.setDirty(True))
        self.connectPassword.textChanged.connect(lambda: self.setDirty(True))
        self.connectPoll.currentIndexChanged.connect(lambda: self.setDirty(True))
        self.connectKeepAlive.currentIndexChanged.connect(lambda: self.setDirty(True))
        self.connectAlt.toggled.connect(lambda: self.setDirty(True))
        self.connectDefault.toggled.connect(lambda: self.setDirty(True))
コード例 #10
0
def is_silent(values, feature, parent):
    try:
        return (int(time.time()) - int(feature['updated'])) >= int(Settings.get('updatedTimeout', 15))
    except KeyError:
        return 0
コード例 #11
0
 def freshInstall(self):
     version = Settings.get('version')
     current = Settings.getMeta('version')
     return current != version
コード例 #12
0
 def freshInstall(self):
     version = Settings.get('version')
     current = Settings.getMeta('version')
     return current != version
コード例 #13
0
    def setupUi(self):
        super(tlBrokerConfig, self).setupUi(self)

        self.connectHelp.clicked.connect(self._help)
        self.connectTest.clicked.connect(self._test)

        self.connectName.setValidator(
            QRegExpValidator(QRegExp("^[a-zA-Z0-9\s]+"), self))
        self.connectHost.setValidator(
            QRegExpValidator(QRegExp("^[a-z0-9\-\.]+"), self))
        self.connectHostAlt.setValidator(
            QRegExpValidator(QRegExp("^[a-z0-9\-\.]+"), self))

        self.Tabs.setCurrentIndex(self.kBrokerConfigTabId)  # First index

        # if Modal create mode
        self.setName(self._broker.name())
        self.setHost(self._broker.host())
        self.setPort(str(self._broker.port()))

        self.setHostAlt(self._broker.hostAlt())
        self.setPortAlt(str(self._broker.portAlt()))

        self.setPoll(str(self._broker.poll()))
        self.setKeepAlive(str(self._broker.keepAlive()))

        self.setUsername(self._broker.username())
        self.setPassword(self._broker.password())

        self._connectedTLayers = []
        self._featureListItems = {}
        self._refreshFeature = QTimer()
        self._refreshFeature.setSingleShot(True)
        self._refreshFeature.timeout.connect(self._updateFeatureList)
        self.Tabs.currentChanged.connect(lambda: self._refreshFeature.start(3))
        QgsMapLayerRegistry.instance().layersRemoved.connect(
            self._updateFeatureList)
        QgsProject.instance().layerLoaded.connect(self._updateFeatureList)

        self.tableFeatureList.doubleClicked.connect(self._showFeatureDialog)
        self.tableFeatureList.clicked.connect(self._zoomToFeature)

        self.connectApply.setEnabled(False)

        if self._mode == Constants.Create:  # Create Layer - so Modal
            self.connectPoll.setCurrentIndex(
                self.connectPoll.findText(Settings.get('mqttPoll', 5)))
            self.connectApply.setText(
                _translate("tlBrokerConfig", "Create", None))
            self.connectApply.clicked.connect(self.accept)
            self.dockWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
            self.dockWidget.setWindowTitle(
                _translate("tlBrokerConfig", "Add Broker", None))
            #self.Tabs.setEnabled(False)
            #   self.connectFarmSenseServer.setEnabled(False)
        elif self._mode == Constants.Update:

            if self._broker.useAltConnect():
                self.connectDefault.setChecked(False)
                self.connectAlt.setChecked(True)
            else:
                self.connectDefault.setChecked(True)
                self.connectAlt.setChecked(False)

            self.dockWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
            self.dockWidget.setWindowTitle(
                _translate("tlBrokerConfig", "Configure ", None) +
                self.getName())
            self.connectApply.setText(
                _translate("tlBrokerConfig", "Apply", None))
            self.dockWidget.visibilityChanged.connect(self.tearDown)

        self.connectName.textChanged.connect(lambda: self.setDirty(True))
        self.connectHost.textChanged.connect(lambda: self.setDirty(True))
        self.connectPort.textChanged.connect(lambda: self.setDirty(True))
        self.connectHostAlt.textChanged.connect(lambda: self.setDirty(True))
        self.connectPortAlt.textChanged.connect(lambda: self.setDirty(True))
        self.connectUsername.textChanged.connect(lambda: self.setDirty(True))
        self.connectPassword.textChanged.connect(lambda: self.setDirty(True))
        self.connectPoll.currentIndexChanged.connect(
            lambda: self.setDirty(True))
        self.connectKeepAlive.currentIndexChanged.connect(
            lambda: self.setDirty(True))
        self.connectAlt.toggled.connect(lambda: self.setDirty(True))
        self.connectDefault.toggled.connect(lambda: self.setDirty(True))