Beispiel #1
0
    def __init__(self,
                 pathManager=None,
                 packageCheckEnabled=False,
                 packageCheckFrequency=240):
        self._path_manager = pathManager
        self._signal_channel = "package_manager"
        self._signal_dispatcher = SignalDispatcher(self._signal_channel)
        self.signal_channel_prefix = "package_manager"

        pollapli_package = Package(name="Pollapli",
                                   description="core package",
                                   version="0.5.0",
                                   installed=True)
        pollapli_package.cid = uuid.UUID(
            "23b0d813-a6b2-461a-88ad-a7020ae67742")
        self._installed_packages = {pollapli_package.cid: pollapli_package}
        self._available_packages = {}

        self.package_check_frequency = packageCheckFrequency
        self.package_check_enabled = packageCheckEnabled
        self.package_list_url = "http://kaosat.net/pollapli/pollapli_packages.json"
        self._package_check = task.LoopingCall(self.refresh_packageList)

        self._addon_path = "."
        self.updates_path = "."
        self._max_download_attempts = 5
        self._downloader = DownloaderWithProgress()
Beispiel #2
0
 def __init__(self, parentEnvironment):
     self._parentEnvironment = parentEnvironment
     self._persistenceLayer = parentEnvironment._persistenceLayer
     self._tasks = {}
     self._signal_channel = "task_manager"
     self._signal_dispatcher = SignalDispatcher(self._signal_channel)
     self.signal_channel_prefix = "environment_"+str(self._parentEnvironment.cid)
Beispiel #3
0
    def __init__(self,
                 deviceType="",
                 connectionType="",
                 hardware_interface_klass=None,
                 logicHandlerKlass=None,
                 protocol=None,
                 options={},
                 *args,
                 **kwargs):
        self.driverType = self.__class__.__name__.lower()
        self.deviceType = deviceType
        self.connectionType = connectionType
        self.extra_params = options
        self.protocol = protocol
        self.hardware_interface_klass = hardware_interface_klass
        self.logicHandlerKlass = logicHandlerKlass

        self.deviceId = None
        """will be needed to identify a specific device, as the system does not work base on ports"""

        self._signal_dispatcher = None
        self.signal_channel_prefix = ""
        self._signal_channel = ""

        self.isConfigured = False  #when the port association has not been set
        self.is_handshake_ok = False
        self.is_authentification_ok = False
        self.isConnected = False
        self.isPluggedIn = False
        self.autoConnect = False  #if autoconnect is set to true, the device will be connected as soon as a it is plugged in and detected

        self.connectionErrors = 0
        self.maxConnectionErrors = 2
        self.connectionTimeout = 4

        self.connectionMode = 1
        self.deferred = defer.Deferred()
        """just for future reference : this is not implemented but would be a declarative way to 
        define the different "configuration steps" of this driver"
        *basically a dictonary with keys beeing the connection modes, and values a list of strings
        representing the methods to call
        *would require a "validator"  of sorts (certain elements need to be mandatory : such as the
        validation/setting of device ids
        """
        configSteps = {}
        configSteps[0] = ["_handle_deviceHandshake", "_handle_deviceIdInit"]
        configSteps[1] = [
            "_handle_deviceHandshake", "_handle_deviceIdInit",
            "some_other_method"
        ]

        #just a test
        self._signal_dispatcher = SignalDispatcher("driver_manager")
        """for exposing capabilites"""
        self.endpoints = []
Beispiel #4
0
    def test_with_basic_message(self):
        iSignalDispatcher = SignalDispatcher("test_channel")

        def signalHandler(signal=None,
                          sender=None,
                          realsender=None,
                          data=None,
                          time=None,
                          *args,
                          **kwargs):
            self.assertEquals(signal, "just a test message")
            self.assertEquals(sender, "test_channel")

        iSignalDispatcher.add_handler(channel="test_channel",
                                      handler=signalHandler)
        iSignalDispatcher.send_message("just a test message")
Beispiel #5
0
 def __init__(self,
              name="base_device",
              description="base device",
              environment="Home"):
     """
     :param environment : just a tag to identify the environment this device
     belongs to
     """
     BaseDeviceComponent.__init__(self,
                                  None,
                                  name="base_device",
                                  description="base device")
     self.name = name
     self.description = description
     self.status = "inactive"
     self.environment = environment
     self.driver = None
     self._signal_channel = "device %s" % self.cid
     self._signal_dispatcher = SignalDispatcher(self._signal_channel)
Beispiel #6
0
    def __init__(self,
                 hardware_id=None,
                 auto_connect=False,
                 max_connection_errors=2,
                 connection_timeout=4,
                 do_hanshake=False,
                 do_authentification=False):
        """
        autoconnect:if autoconnect is True,device will be connected as soon as
        it is plugged in and detected
        max_connection_errors: the number of connection errors above which
        the driver gets disconnected
        connection_timeout: the number of seconds after which the driver
        gets disconnected (only in the initial , configuration phases by
        default)
        """
        BaseComponent.__init__(self, parent=None)
        self.auto_connect = auto_connect
        self.max_connection_errors = max_connection_errors
        self.connection_timeout = connection_timeout
        self.do_authentification = do_authentification
        self.do_handshake = do_hanshake
        self._hardware_interface = None
        self.hardware_id = hardware_id
        self.is_configured = False
        self.is_bound = False  # when port association has not been set
        self.is_handshake_ok = False
        self.is_authentification_ok = False
        self.is_connected = False
        self.is_bound = False
        self.is_busy = False

        self.errors = []
        self.connection_mode = 1
        self._connection_errors = 0
        self._connection_timeout = None
        self.deferred = defer.Deferred()

        self._signal_channel_prefix = ""
        self._signal_dispatcher = SignalDispatcher("driver_manager")
 def __init__(self,persistenceLayer = None):
     self._persistenceLayer = persistenceLayer
     self._logger=log.PythonLoggingObserver("dobozweb.core.components.environments.environmentManager")
     self._environments = {}
     self._signal_channel="environment_manager"
     self._signal_dispatcher = SignalDispatcher(self._signal_channel)