Exemplo n.º 1
0
    def test_msubscribe(self ):
        mode_choices = [SubscriptionMode.Monitor(delta=0.01), SubscriptionMode.Scan(period=1)]
        modes = [random.choice(mode_choices) for _ in self.pvs]
        futures = controller.msubscribe( self.pvs, modes )

        results = [ fut.get() for fut in futures ]
        
        self.assertTrue(all(results))
        pvs = dict(controller.list_subscribed())
        for pv in self.pvs:
            self.assertIn(pv, pvs)
Exemplo n.º 2
0
    def _subscribe(self):
        body_json = self.request.body
        if not body_json:
            self.fail("Empty request")
        try:
            body = json.loads(body_json)
            # body should of the form
            # [ {pvname: ..., mode: ...}, {pvname: ..., mode: ...}, ... ]
            pvnames = []
            modes = []
            for subscr_dict in body:
                pvnames.append(subscr_dict["pvname"])
                modes.append(SubscriptionMode.parse(subscr_dict["mode"]))

            futures = controller.msubscribe(pvnames, modes)
            results = dict((pvname, f.get(TIMEOUT)) for pvname, f in zip(pvnames, futures))
            self.win(results)
        except Exception as e:
            logger.exception(e)
            self.fail(str(e))