Ejemplo n.º 1
0
    def __init__(
            self,
            actors,
            csp_solver_config,
            multiprocessing_pool=None,
            **kwargs
            ):
        self.multiprocessing_pool = multiprocessing_pool

        self.actors_cls = None
        for actor in actors:
            if not isinstance(actor, AbstractActor):
                raise Exception("Please pass a valid "
                                "AbstractActor instance, not '%s'"
                % actor
                )

            if (self.actors_cls
                and not actor.__class__ == self.actors_cls):
                raise Exception("Controller "
                    "can only handle Actors of "
                    "the same class."
                )
            self.actors_cls = actor.__class__

        assert isinstance(actors, list)
        self._actors = actors
        AbstractActor.__init__(self)

        self._csp_solver_config = csp_solver_config
Ejemplo n.º 2
0
    def __init__(self, uri, get_timeout=5, **kwargs):
        self._uri = uri

        self._get_value_uri = urlparse.urljoin(self._uri, '/')
        self._set_value_uri = self._get_value_uri
        self._get_value_range_uri = urlparse.urljoin(self._uri, '/vr/')

        self.get_timeout = get_timeout
        AbstractActor.__init__(self, **kwargs)
Ejemplo n.º 3
0
    def __init__(
            self,
            uri,
            get_timeout=5,
            **kwargs
            ):
        self._uri = uri

        self._get_value_uri = urlparse.urljoin(self._uri, '/')
        self._set_value_uri = self._get_value_uri
        self._get_value_range_uri = urlparse.urljoin(self._uri, '/vr/')

        self.get_timeout = get_timeout
        AbstractActor.__init__(self, **kwargs)
Ejemplo n.º 4
0
    def test_abstract_interface(self):
        actor = AbstractActor()
        assert actor.id is not None

        with self.assertRaises(NotImplementedError):
            actor.get_value()

        with self.assertRaises(NotImplementedError):
            actor.get_value_range()

        with self.assertRaises(NotImplementedError):
            actor.set_value(1)
Ejemplo n.º 5
0
    def __init__(self,
                 actors,
                 csp_solver_config,
                 multiprocessing_pool=None,
                 **kwargs):
        self.multiprocessing_pool = multiprocessing_pool

        self.actors_cls = None
        for actor in actors:
            if not isinstance(actor, AbstractActor):
                raise Exception("Please pass a valid "
                                "AbstractActor instance, not '%s'" % actor)

            if (self.actors_cls and not actor.__class__ == self.actors_cls):
                raise Exception("Controller "
                                "can only handle Actors of "
                                "the same class.")
            self.actors_cls = actor.__class__

        assert isinstance(actors, list)
        self._actors = actors
        AbstractActor.__init__(self)

        self._csp_solver_config = csp_solver_config