def __init__(self, context=None):

        # use PID or uuid as unique identifier for this progress
        #self.pid = os.getpid()
        self.pid = uuid.uuid4().fields[0]

        # ZeroMQ context setup
        if not context: context = zmq.Context()

        # FPGA request socket
        self.socket_request = context.socket(zmq.PUB)
        self.socket_request.connect("tcp://localhost:%s" %
                                    options.FPGA_MAP_REQUEST_PORT)

        # FPGA answer socket
        self.socket_answer = context.socket(zmq.SUB)
        self.socket_answer.setsockopt(zmq.SUBSCRIBE, struct.pack(
            'I', self.pid))  # Filter only your own packets
        self.socket_answer.connect("tcp://localhost:%s" %
                                   options.FPGA_MAP_ANSWER_PORT)

        self._token = 0
        self._pending = collections.deque()

        # checking if FPGA is here for 5 sec.
        tries = 50
        self.socket_answer.setsockopt(zmq.RCVTIMEO, 100)  # Set timout
        while 1:
            try:
                self.write_reg(127, '')
                break
            except zmq.ZMQError as error:
                tries -= 1
                if tries == 0:
                    raise error
        self.socket_answer.setsockopt(zmq.RCVTIMEO,
                                      options.MESSAGE_TIMEOUT)  # Set timout

        self.power = fpga_map.Power(self)
        self.edfa = fpga_map.EDFA(self)
        self.dac = fpga_map.DAC(self)
Exemple #2
0
import ipc_helper
import fpga_map as mmap
import time
import file_manager
import traceback
import options
import dac
import math
import hashlib
import datetime

#For basic testing of calibration laser and seed laser aliveness. Can be upgraded as necessary (e.g. expected parameter values)

# define fpga interface
fpga = ipc_helper.FPGAClientInterface()
power = mmap.Power(fpga)  # power sub-interface

len_pass_string = 100


def print_test(fo, name):
    print(name + ' ' + '.' * (len_pass_string - len(name)) + ' ', end='')
    fo.write('--- %s Starting %s ---\n' %
             ("(" + str(datetime.datetime.now())[0:23] + ")", name))


def pass_test(fo):
    print('Pass')
    fo.write('--- %s Pass ---\n' %
             ("(" + str(datetime.datetime.now())[0:23] + ")"))
Exemple #3
0
import sys
import os
import zmq
import json
import time
import struct
sys.path.append('../lib/')
sys.path.append('/root/lib/')
from options import *
from ipc_packets import PATControlPacket, PATStatusPacket
from zmqTxRx import recv_zmq, send_zmq
import ipc_helper
import fpga_map as mmap
fpga = ipc_helper.FPGAClientInterface()
power = mmap.Power(fpga)

#PAT Status Flag List
# pat_status_list = [PAT_STATUS_CAMERA_INIT, PAT_STATUS_STANDBY, PAT_STATUS_STANDBY_CALIBRATED, PAT_STATUS_STANDBY_SELF_TEST_PASSED, PAT_STATUS_STANDBY_SELF_TEST_FAILED, PAT_STATUS_MAIN]
# pat_status_names = ['CAMERA INIT', 'STANDBY', 'STANDBY_CALIBRATED', 'STANDBY_SELF_TEST_PASSED', 'STANDBY_SELF_TEST_FAILED', 'MAIN']

#PAT Command List
cmd_list = [
    PAT_CMD_START_PAT, PAT_CMD_START_PAT_OPEN_LOOP,
    PAT_CMD_START_PAT_STATIC_POINT, PAT_CMD_START_PAT_BUS_FEEDBACK,
    PAT_CMD_START_PAT_OPEN_LOOP_BUS_FEEDBACK, PAT_CMD_UPDATE_TX_OFFSET_X,
    PAT_CMD_UPDATE_TX_OFFSET_Y, PAT_CMD_END_PAT, PAT_CMD_GET_IMAGE,
    PAT_CMD_CALIB_TEST, PAT_CMD_CALIB_LASER_TEST, PAT_CMD_FSM_TEST,
    PAT_CMD_BCN_ALIGN, PAT_CMD_TX_ALIGN, PAT_CMD_UPDATE_FSM_X,
    PAT_CMD_UPDATE_FSM_Y, PAT_CMD_SELF_TEST, PAT_CMD_END_PROCESS,
    PAT_CMD_SET_BEACON_X, PAT_CMD_SET_BEACON_Y, PAT_CMD_SET_BEACON_WINDOW_SIZE,