Example #1
0
    def __init__(self, cfg=None, log_level=logs.ERROR):
        """Initialize the Instrument.

    Args:
      cfg: Holds connectivity and settings parameters.
           cfg = { "connection": {"name": "VSA",
                            "use": True,
                            "protocol": "visa",
                            "addr": "10.0.0.189",
                            "debug": False,
                            "timeout": 20
                            },
                    "cfg": {"Freq": "2110",
                            "BW": "10",
                            "ExtAtt": "49",
                            "Duplex": "FDD",
                            "Dir": "DL"
                            }
                  }
      log_level: one of logging.levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
    """
        global logger
        logger = logs.get_log("VisaWrap", level=log_level)
        self.inst = None
        self.drv = None
        self.set_error()
        if not cfg:
            self.set_error("No Configuration parameters provided.")
            return
        self.cfg = cfg
        if "connection" not in cfg or not cfg["connection"]:
            self.set_error("Connectivity Parameters not provided")
            return
        con = cfg["connection"]
        self.debug = con.get("debug", False)
        self.ip_address = str(con.get("addr", "127.0.0.1"))
        self.timeout = con.get("timeout", 15)
        self.instance = str(con.get("instance", "inst0"))

        try:
            self.inst = vxi11.Vxi11Device(self.ip_address, self.instance)
            vxi11.timeout(self.timeout)
        except Exception:
            self.set_error("Initialization error, IP:%s" % self.ip_address)
            return
Example #2
0
  def __init__(self, cfg=None, log_level=logs.ERROR):
    """Initialize the Instrument.

    Args:
      cfg: Holds connectivity and settings parameters.
           cfg = { "connection": {"name": "VSA",
                            "use": True,
                            "protocol": "visa",
                            "addr": "10.0.0.189",
                            "debug": False,
                            "timeout": 20
                            },
                    "cfg": {"Freq": "2110",
                            "BW": "10",
                            "ExtAtt": "49",
                            "Duplex": "FDD",
                            "Dir": "DL"
                            }
                  }
      log_level: one of logging.levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
    """
    global logger
    logger = logs.get_log("VisaWrap", level=log_level)
    self.inst = None
    self.drv = None
    self.set_error()
    if not cfg:
      self.set_error("No Configuration parameters provided.")
      return
    self.cfg = cfg
    if "connection" not in cfg or not cfg["connection"]:
      self.set_error("Connectivity Parameters not provided")
      return
    con = cfg["connection"]
    self.debug = con.get("debug", False)
    self.ip_address = str(con.get("addr", "127.0.0.1"))
    self.timeout = con.get("timeout", 15)
    self.instance = str(con.get("instance", "inst0"))

    try:
      self.inst = vxi11.Vxi11Device(self.ip_address, self.instance)
      vxi11.timeout(self.timeout)
    except Exception:
      self.set_error("Initialization error, IP:%s"%self.ip_address)
      return
Example #3
0
import sys

from future.builtins import (ascii, bytes, chr, dict, filter, hex, input,
                             int, map, next, oct, open, pow, range, round,
                             str, super, zip)
import time
from multiprocessing import Process
import pyarrow
from flask import Flask

import config as c
import logs
import utils
from renderer.base_renderer import Renderer

log = logs.get_log(__name__)
app = Flask(__name__)

web_renderer = None

"""
Usage:
Call main.py with --render and navigate to http://0.0.0.0:5000
"""

# TODO: Support rendering saved HDF5 and tfrecord's


def get_web_renderer():
    # Singleton is a hack around difficulties setting up multiple ZMQ contexts on same port in the same process
    global web_renderer
Example #4
0
                             int, map, next, oct, open, pow, range, round,
                             str, super, zip)

import threading
import cv2
import numpy as np
from flask import render_template
from werkzeug.wrappers import Response

from collections import deque

import logs
import config as c
import utils

log = logs.get_log(__name__, 'renderer_log.txt')


class StreamServer(object):
    def __init__(self, app):
        self.app = app
        import zmq

        log.info('Pairing to zmq image stream')
        context = zmq.Context()
        socket = context.socket(zmq.PAIR)
        conn_string = 'tcp://*:%s' % c.STREAM_PORT
        socket.bind(conn_string)
        log.debug('Grabbing images over ZMQ from %s', conn_string)
        self.socket = socket
        self.context = context