def test_get_frame(sim_server, protocol_version): c = Client(sim_server.endpoint) data, metadata = c.next() assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in data assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in metadata if protocol_version == '1.0': assert all('metadata' in src for src in data.values())
def test_pickle(sim_server_pickle): c = Client(sim_server_pickle, ser='pickle') data, metadata = c.next() assert isinstance(data, dict) assert isinstance(metadata, dict) image = data['SPB_DET_AGIPD1M-1/DET/0CH0:xtdf']['image.data'] assert isinstance(image, np.ndarray)
class Tester(): def __init__(self, address, sigint): self.sigint = sigint self.client = Client(address) self.reset() def handler(self, signum, frame): signal.signal(signal.SIGINT, self.sigint) opt = input('Reset? [y/N/e] ("e" to exit): ').lower() if opt.startswith('y'): signal.signal(signal.SIGINT, self.handler) self.reset() self.loop() elif opt.startswith('e'): print('Exiting') sys.exit(0) else: signal.signal(signal.SIGINT, self.handler) self.loop() def reset(self): self.ind = 0 self.old = 0 self.stime = time.time() print('Train ID Diff Frame rate') def loop(self): while True: d, md = self.client.next() tid = d[list(d)[0]]['image.trainId'][0] npulses = d[list(d)[0]]['image.data'].shape[-1] self.ind += 1 tnow = time.time() if self.ind > 1: print('%-10ld %-6d %.3f Hz' % (tid, tid-self.old, self.ind*npulses/(tnow-self.stime))) else: print('-'*30) self.old = tid
def test_pull_socket(sim_push_server): c = Client(sim_push_server.endpoint, sock='PULL') data, metadata = c.next() assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in data assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in metadata
def test_get_frame(sim_server): c = Client(sim_server) data, metadata = c.next() assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in data assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in metadata
def test_protocol_1(sim_server_version_1): c = Client(sim_server_version_1) data, metadata = c.next() assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in data assert 'SPB_DET_AGIPD1M-1/DET/0CH0:xtdf' in metadata assert all('metadata' in src for src in data.values())
from karabo_bridge import Client krb_client = Client("tcp://localhost:4545") for i in range(10): data, metadata = krb_client.next() print("Client : received train ID {}".format( metadata['SPB_DET_AGIPD1M-1/DET/detector']['timestamp.tid'])) det_data = data['SPB_DET_AGIPD1M-1/DET/detector'] print("Client : - detector image shape is {}, {} Mbytes".format( det_data['image.data'].shape, det_data['image.data'].nbytes/1024**2)) print("Client : Client stops reading here")