def __init__(self, url="tcp://127.0.0.1", pub_port=5100, pub_topic="", pub_name="", sub_port=5099, sub_topic="", sub_name=""): """Publisher-Subscriber. This is a shell implementation. Intend to use as a processing unit. First subscribe on a topic, process it, and then publish to a topic """ self.url = url self.pub_port = pub_port self.pub_topic = pub_topic self.pub_name = pub_name self.sub_port = sub_port self.sub_topic = sub_topic self.sub_name = sub_name self.logger = log.get_logger( "PubSuber-{}-{}".format(self.pub_name, self.sub_name), log.INFO, stream=sys.stdout)
def __init__(self, url, port, topic, name): """Subscriber. A general implementation of subscriber. # Arguments url : str address to subscribe port : int port number to listen topic : string set to "" (default) to listen everything. subscribe to specific topics otherwise name : str the name of the subscriber """ self.url = url self.port = port self.sub_url = url+":{}".format(port) self.topic = topic self.name = name self.logger = log.get_logger( "Subscriber-{}".format(self.name), log.INFO, stream=sys.stdout) # initialize socket for subscriber self.init_socket()
def __init__(self, url="tcp://127.0.0.1", port=5100, master_topic="", name=""): """Publisher. A abstract publisher implementation. # Arguments url: str tcp address port : int port number connected by publisher master_topic : str the master topic name, such as davis-1 This is usually a device level identifier. There can be sub-topics under this identifier name : str the name of the publisher """ self.url = url self.port = port self.pub_url = url+":{}".format(port) self.master_topic = master_topic self.name = name self.logger = log.get_logger( "Publisher-{}".format(self.name), log.INFO, stream=sys.stdout) # initialize socket for publisher self.init_socket()
def __init__(self, filename, mode="r", libver="latest", use_wall_clock=True): """AERHDF5Reader. A high performance AER HDF5 Reader for events. WARNING: The use of latest lib version is intended for better performance in IO. This may made the saved volume not compatible with older libraries. We use the wall clock to determine the timestamp. # Arguments filename: str the absolute path of the file to be read. mode: str opening mode. We use "r" as default, it means "read-only, file must exist". You can change to "r+" or "a" for your own need. libver: str We use "latest" as default to get high performance, However, you can see this page to choose the HDF5 library version, See this page for detailed explanation: https://docs.h5py.org/en/stable/high/ file.html?highlight=libver#file-version """ self.filename = filename self.libver = libver self.aer_file = h5py.File( name=filename, mode=mode, libver=libver, rdcc_nbytes=50*1024**2, # 50MB Cache track_order=True # Follow the order of the message ) self.logger = log.get_logger( "HDFReader", log.INFO, stream=sys.stdout) self.logger.info("Getting Device Keys") self.device_keys = self.aer_file.keys() self.logger.info("Getting group keys") self.group_keys = OrderedDict() for device in self.device_keys: self.group_keys[device] = self.aer_file[device].keys()
def __init__(self, url="tcp://127.0.0.1", hub_pub_port=5099, hub_sub_port=5100, aer_hub_name="PyAER Message Hub"): """AER Hub. A central relay that allows multiple publisher and subscriber to use a common port. """ self.url = url self.aer_hub_name = aer_hub_name self.hub_pub_port = hub_pub_port self.hub_sub_port = hub_pub_port self.hub_pub_url = url+":{}".format(hub_pub_port) self.hub_sub_url = url+":{}".format(hub_sub_port) # logger self.logger = log.get_logger( aer_hub_name, log.INFO, stream=sys.stdout) # Initialize sockets self.init_socket()
Email : [email protected] """ from __future__ import print_function, absolute_import import os from collections import OrderedDict import json import yaml import time import importlib.util as imutil import numpy as np import pyaer from pyaer import log from pyaer import libcaer logger = log.get_logger("utils", pyaer.LOG_LEVEL) def get_nanotime(): return str(int(time.time() * 1e9)).encode("utf-8") def import_custom_module(custom_file, custom_class): """Load custom module by file path. # Arguments custom_file: str absolute file path to the custom module file. custom_class: str the class name to import that is in the custom_file """