class BulkIOWebsocketHandler(websocket.WebSocketHandler): data_conversion_map = { 'dataFloat': _floats2bin, 'dataDouble': _doubles2bin, 'dataOctet': _pass_through, 'dataShort': _pass_through } def initialize(self, kind, redhawk=None, _ioloop=None): self.kind = kind self.redhawk = redhawk if not _ioloop: _ioloop = ioloop.IOLoop.current() self._ioloop = _ioloop @gen.coroutine def open(self, *args): try: logging.debug("BulkIOWebsocketHandler open kind=%s, path=%s", self.kind, args) obj, path = yield self.redhawk.get_object_by_path(args, path_type=self.kind) logging.debug("Found object %s", dir(obj)) for p in obj.ports: if p.name == path[0]: if p._direction == 'Uses': data_type = p._using.name namespace = p._using.nameSpace if namespace == 'BULKIO': self.port = obj.getPort(str(path[0])) logging.debug("Found port %s", self.port) self.converter = self.data_conversion_map[data_type] bulkio_poa = getattr(BULKIO__POA, data_type) logging.debug(bulkio_poa) self.async_port = AsyncPort(bulkio_poa, self._pushSRI, self._pushPacket) self._portname = 'myport%s' % id(self) self.port.connectPort(self.async_port.getPort(), self._portname) break else: raise ValueError("Port '%s' is not a BULKIO port" % path[0]) else: raise ValueError("Port '%s' is not a uses" % path[0]) else: raise ValueError("Could not find port of name '%s'" % path[0]) except ResourceNotFound, e: self.write_message(dict(error='ResourceNotFound', message=str(e))) self.close() except Exception, e: logging.exception('Error with request %s' % self.request.full_url()) self.write_message(dict(error='SystemError', message=str(e))) self.close()
def open(self, *args): try: logging.debug("BulkIOWebsocketHandler open kind=%s, path=%s", self.kind, args) obj, path = yield self.redhawk.get_object_by_path( args, path_type=self.kind) logging.debug("Found object %s", dir(obj)) for p in obj.ports: if p.name == path[0]: if p._direction == 'Uses': data_type = p._using.name namespace = p._using.nameSpace if namespace == 'BULKIO': self.port = obj.getPort(str(path[0])) logging.debug("Found port %s", self.port) self.converter = self.data_conversion_map[ data_type] bulkio_poa = getattr(BULKIO__POA, data_type) logging.debug(bulkio_poa) self.async_port = AsyncPort( bulkio_poa, self._pushSRI, self._pushPacket) self._portname = 'myport%s' % id(self) self.port.connectPort(self.async_port.getPort(), self._portname) break else: raise ValueError("Port '%s' is not a BULKIO port" % path[0]) else: raise ValueError("Port '%s' is not a uses" % path[0]) else: raise ValueError("Could not find port of name '%s'" % path[0]) except ResourceNotFound, e: self.write_message(dict(error='ResourceNotFound', message=str(e))) self.close()
def open(self, *args): try: logging.debug("BulkIOWebsocketHandler open kind=%s, path=%s", self.kind, args) obj, path = yield self.redhawk.get_object_by_path(args, path_type=self.kind) logging.debug("Found object %s", dir(obj)) for p in obj.ports: if p.name == path[0]: if p._direction == 'Uses': data_type = p._using.name namespace = p._using.nameSpace if namespace == 'BULKIO': self.port = obj.getPort(str(path[0])) logging.debug("Found port %s", self.port) self.converter = self.data_conversion_map[data_type] bulkio_poa = getattr(BULKIO__POA, data_type) logging.debug(bulkio_poa) self.async_port = AsyncPort(bulkio_poa, self._pushSRI, self._pushPacket) self._portname = 'myport%s' % id(self) self.port.connectPort(self.async_port.getPort(), self._portname) break else: raise ValueError("Port '%s' is not a BULKIO port" % path[0]) else: raise ValueError("Port '%s' is not a uses" % path[0]) else: raise ValueError("Could not find port of name '%s'" % path[0]) except ResourceNotFound, e: self.write_message(dict(error='ResourceNotFound', message=str(e))) self.close()
class BulkIOWebsocketHandler(websocket.WebSocketHandler): data_conversion_map = { 'dataFloat': _floats2bin, 'dataDouble': _doubles2bin, 'dataOctet': _pass_through, 'dataShort': _pass_through } def initialize(self, kind, redhawk=None, _ioloop=None): self.kind = kind self.redhawk = redhawk if not _ioloop: _ioloop = ioloop.IOLoop.current() self._ioloop = _ioloop @gen.coroutine def open(self, *args): try: logging.debug("BulkIOWebsocketHandler open kind=%s, path=%s", self.kind, args) obj, path = yield self.redhawk.get_object_by_path( args, path_type=self.kind) logging.debug("Found object %s", dir(obj)) for p in obj.ports: if p.name == path[0]: if p._direction == 'Uses': data_type = p._using.name namespace = p._using.nameSpace if namespace == 'BULKIO': self.port = obj.getPort(str(path[0])) logging.debug("Found port %s", self.port) self.converter = self.data_conversion_map[ data_type] bulkio_poa = getattr(BULKIO__POA, data_type) logging.debug(bulkio_poa) self.async_port = AsyncPort( bulkio_poa, self._pushSRI, self._pushPacket) self._portname = 'myport%s' % id(self) self.port.connectPort(self.async_port.getPort(), self._portname) break else: raise ValueError("Port '%s' is not a BULKIO port" % path[0]) else: raise ValueError("Port '%s' is not a uses" % path[0]) else: raise ValueError("Could not find port of name '%s'" % path[0]) except ResourceNotFound, e: self.write_message(dict(error='ResourceNotFound', message=str(e))) self.close() except Exception, e: logging.exception('Error with request %s' % self.request.full_url()) self.write_message(dict(error='SystemError', message=str(e))) self.close()